| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
题解: 差分+贪心#include<iostream>
#include<set>
using namespace std;
#define N 10004
#define pii pair<int, int>
int n, m, p, h;
int cha[N];
set<pii> U;
int main() {
ios::sync_with_stdio(0);
cin >> n >> p >> h >> m;
for(int i = 1; i <= m; ++ i) {
pii IN;
cin >> IN.first >> IN.second;
if(IN.first > IN.second) swap(IN.first, IN.second);
if(U.count(IN)) continue;
U.insert(IN);
cha[IN.first + 1] -= 1;
cha[IN.second] += 1;
}
for(int i = 1; i <= n; ++ i) {
cha[i] += cha[i - 1];
cout << h + cha[i] << endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator