标签:des style blog http io ar color os sp
5 1 1 5 1 7 1 3 3 5 5
1 2 1 1 0
//46MS 500K #include<stdio.h> #include<string.h> int C[32007],ans[32007]; int N=32007; int lowbit(int x) { return x&(-x); } void add(int pos,int val) { while(pos<N) { C[pos]+=val; pos+=lowbit(pos); } } int getsum(int x) { int result=0; while(x>0) { result+=C[x]; x-=lowbit(x); } return result; } int main() { int n; while(scanf("%d",&n)!=EOF) { memset(C,0,sizeof(C)); memset(ans,0,sizeof(ans)); int x,y; for(int i=0;i<n;i++) { scanf("%d%d",&x,&y); ans[getsum(x+1)]++; add(x+1,1); } for(int i=0;i<n;i++) printf("%d\n",ans[i]); } }
标签:des style blog http io ar color os sp
原文地址:http://blog.csdn.net/crescent__moon/article/details/41725545