标签:
5 1 1 5 1 7 1 3 3 5 5
1 2 1 1 0
<span style="font-size:18px;">#include <iostream> #include <cstdio> #include <cstring> #include <stack> #include <queue> #include <map> #include <set> #include <vector> #include <cmath> #include <algorithm> using namespace std; const double eps = 1e-6; const double pi = acos(-1.0); const int INF = 0x3f3f3f3f; const int MOD = 1000000007; #define ll long long #define CL(a,b) memset(a,b,sizeof(a)) #define MAXN 32010 int n,a[MAXN],sum[MAXN]; int lowbit(int x){ return x&(-x);} int Sum(int n)///前n项的和 { int s = 0; while(n > 0) { s += a[n]; n -= lowbit(n); } return s; } void add(int x)///增加某个元素的大小 { while(x <= MAXN) { ++a[x]; x += lowbit(x); } } int main() { int x,y; while(~scanf("%d",&n)) { CL(a, 0); CL(sum, 0); for(int i=0; i<n; i++) { scanf("%d%d",&x,&y); x++; sum[Sum(x)]++; add(x); } for(int i=0; i<n; i++) cout<<sum[i]<<endl; } return 0; } </span>
标签:
原文地址:http://blog.csdn.net/d_x_d/article/details/50759728