标签:
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 42898 | Accepted: 18664 |
Description
Input
Output
Sample Input
5 1 1 5 1 7 1 3 3 5 5
Sample Output
1 2 1 1 0
Hint
Source
#include<cstdio> #include<iostream> #include<algorithm> #include<cstring> using namespace std; const int MAXN=15100,MAXX=32100; int c[MAXX]; int ans[MAXN]; int lowbit(int x) { return x&(-x); } void add(int i,int val) { for(i; i<=MAXX; i+=lowbit(i)) c[i]+=val; } int sum(int i) { int s=0; for(i; i>0; i-=lowbit(i)) s+=c[i]; return s; } int main() { int i,n; int x,y; while(scanf("%d",&n)!=EOF) { memset(c,0,sizeof(c)); memset(ans,0,sizeof(ans)); for(i=0; i<n; i++) { scanf("%d%d",&x,&y); int temp=sum(x+1); ans[temp]++; add(x+1,1); } for(i=0; i<n; i++) printf("%d\n",ans[i]); } return 0; }
标签:
原文地址:http://www.cnblogs.com/GeekZRF/p/5914470.html