hdu1556 Color the ball

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 100100;
int n;
int value[maxn];
int res[maxn]; int main()
{
int a, b;
while(scanf("%d", &n) != EOF && n) {
for(int i = 0; i <= n; i++) {
value[i] = 0;
res[i] = 0;
}
for(int i = 1; i <= n; i++) {
scanf("%d%d", &a, &b);
value[a] += 1;
value[b+1] += -1;
}
int result = 0;
for(int i = 1; i <= n; i++) {
result += value[i];
res[i] = result;
}
for(int i = 1; i < n; i++) {
printf("%d ", res[i]);
}
printf("%d\n", res[n]);
}
return 0;
}
上一篇:BZOJ4278 [ONTAK2015]Tasowanie[后缀数组+贪心]


下一篇:jquery知识巩固