标签:printf instead turn win end represent can maps oid
Input
Output
Sample Input
5 1 1 5 1 7 1 3 3 5 5
Sample Output
1 2 1 1 0
Hint
#include<iostream> #include<cstdio> #include<cstring> using namespace std; //int mod(int x,int y) {return x-x/y*y;} #define M 32009 int b[M],a[M]; int lowbit(int x){ return x&(-x); } void add(int x,int date){ while(x<M){ a[x] += date; x += lowbit(x); } } int sum(int x){ int res = 0; while(x>0){ res += a[x]; x -= lowbit(x); } return res; } int main(){ int i,n,x,y; while(scanf("%d",&n)!=EOF){ memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); for(i=0;i<n;i++){ scanf("%d%d",&x,&y); x+=1; b[sum(x)]++; add(x,1); } for(i=0;i<n;i++) printf("%d\n",b[i]); } return 0; }
标签:printf instead turn win end represent can maps oid
原文地址:http://www.cnblogs.com/kls123/p/7512220.html