题目:Stars

 

#include <stdio.h>
#include <string.h>

const int N = 32005;

int C[N];

int level[N];

int Lowbit(int x)
{
    return x & (-x);
}

void Update(int x)
{
    int i;
    for(i=x;i<=N;i+=Lowbit(i))
    {
        C[i]++;
    }
}

int GetSum(int x)
{
    int sum=0,i;
    for(i=x;i>0;i-=Lowbit(i))
    {
        sum+=C[i];
    }
    return sum;
}

int main()
{
    int n,x,y;
    while(~scanf("%d",&n))
    {
        memset(C,0,sizeof(C));
        memset(level,0,sizeof(level));
        for(int i=0;i<n;i++)
        {
            scanf("%d%d",&x,&y);
            ++x;
            level[GetSum(x)]++;
            Update(x);
        }
        for(int i=0;i<n;i++)
           printf("%d\n",level[i]);
    }
    return 0;
}