标签:des blog http io os ar for sp strong
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 33344 | Accepted: 14560 |
Description

Input
Output
Sample Input
5 1 1 5 1 7 1 3 3 5 5
Sample Output
1 2 1 1 0
Hint
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
int lev[32010];
int c[32010];
int lowbit(int x)
{
return x&(-x);
}
int SUM(int n)
{
int sum=0;
while(n>0)
{
sum+=c[n];
n-=lowbit(n);
}
return sum ;
}
void modify( int i )
{
while(i<=32001)
{
c[i]+=1;
i=i+lowbit(i);
}
}
int main()
{
int n;
int i, j, k;
int u, v;
while(scanf("%d", &n)!=EOF)
{
memset(lev, 0, sizeof(lev)) ;
memset(c, 0, sizeof(c)) ;
for(i=0; i<n; i++)
{
scanf("%d %d", &u, &v);
++u;
lev[SUM(u)]++;
modify(u);
}
for(j=0; j<n; j++)
{
printf("%d\n", lev[j] );
}
}
return 0;
}
标签:des blog http io os ar for sp strong
原文地址:http://www.cnblogs.com/yspworld/p/4063724.html