Created
November 18, 2014 15:48
-
-
Save SilverRainZ/fabfb5a0801504dc8b83 to your computer and use it in GitHub Desktop.
RIGHT_Stars
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<cstdio> | |
#include<cstring> | |
using namespace std; | |
const int MAXN = 32005; | |
int c[MAXN],level[MAXN],n; | |
int lowbit(int x){return x & (-x);} | |
// 求前n项的和 | |
int sum(int n){ | |
int sum = 0; | |
while(n > 0){ | |
sum += c[n]; | |
n -= lowbit(n); | |
} | |
return sum; | |
} | |
// 增加某个元素的大小 | |
void add(int x){ | |
while(x <= MAXN){ | |
++c[x]; | |
x += lowbit(x); | |
} | |
} | |
int main(){ | |
int n,x,y; | |
while(~scanf("%d",&n)){ | |
memset(level, 0, sizeof(level)); | |
memset(c, 0, sizeof(c)); | |
for(int i=0; i<n; ++i) { | |
scanf("%d%d",&x,&y); | |
++x; | |
level[sum(x)]++; | |
add(x); | |
} | |
for(int i=0; i<n; ++i) | |
printf("%d\n",level[i]); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment