标签:des style blog http color io os java ar
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4897 Accepted Submission(s): 1934
1 #include<cstdio> 2 #include<iostream> 3 #include<cstring> 4 #include<stdlib.h> 5 #include<algorithm> 6 using namespace std; 7 const int MAXN=32000+10; 8 const int N=15000+10; 9 int cnt[N],c[MAXN]; 10 int lowbit(int x) 11 { 12 return x&(-x); 13 } 14 int update(int i,int val) 15 { 16 while(i<=MAXN) 17 { 18 c[i]+=val; 19 i+=lowbit(i); 20 } 21 } 22 int sum(int i) 23 { 24 int ans=0; 25 while(i>0) 26 { 27 ans+=c[i]; 28 i-=lowbit(i); 29 } 30 return ans; 31 } 32 int main() 33 { 34 int n; 35 int x,y; 36 while(scanf("%d",&n)!=EOF) 37 { 38 memset(cnt,0,sizeof(cnt)); 39 memset(c,0,sizeof(c)); 40 for(int i=0;i<n;i++) 41 { 42 scanf("%d %d",&x,&y); 43 cnt[sum(x+1)]++; 44 update(x+1,1); 45 } 46 for(int i=0;i<n;i++) 47 printf("%d\n",cnt[i]); 48 } 49 return 0; 50 }
标签:des style blog http color io os java ar
原文地址:http://www.cnblogs.com/clliff/p/3967312.html