传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1556
//简单树状数组练习
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
const int maxn =1e5+10;
int tree[maxn];
int n;
int lowbit(int x){
return x&(-x);
}
void add(int x,int val){
while(x<=n){
tree[x]+=val;
x+=lowbit(x);
}
}
int query(int x){
int res=0;
while(x){
res+=tree[x];
x-=lowbit(x);
}
return res;
}
int main(){
while(~scanf("%d",&n)&&n){
memset(tree,0,sizeof(tree));
int x,y;
for(int i=1;i<=n;i++)
{
scanf("%d%d",&x,&y);
add(x,1);
add(y+1,-1);
}
for(int i=1;i<=n;i++){
if(i==n){
printf("%d\n",query(i));
}
else
printf("%d ",query(i));
}
}
}