#include <bits/stdc++.h>using namespace std;const int MAXN = 1e5 + 10;int n;int bit[MAXN];int lowbit(int x) { return x & -x;}void add(int x, int y) { while (x <= n) { bit[x] += y; x += lowbit(x); }}int sum(int x) { int res = 0; while (x) { res += bit[x]; x -= lowbit(x); } return res;}int main() { while (scanf("%d", &n), n) { for (int i = 1; i <= n; i++) bit[i] = 0; for (int i = 1; i <= n; i++) { int l, r; scanf("%d%d", &l, &r); add(l, 1); add(r + 1, -1); } for (int i = 1; i <= n; i++) PRintf("%d%c", sum(i), i == n ? '/n' : ' '); } return 0;}
新闻热点
疑难解答