标签:des style blog http color os io strong
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 32473 | Accepted: 14184 |
Description

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 <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#define init(a) memset(a,0,sizeof(a))
using namespace std;
#define MAX INT_MAX
#define MIN INT_MIN
#define LL __int64
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
const int maxn = 50010;
using namespace std;
int c[maxn];
int lev[maxn];
int lowbit(int x)
{
return x&(-x);
}
void add(int i,int w)//增减
{
while(i<=32010)
{
c[i]+=w;
i+=lowbit(i);
}
}
int sum(int i)//计算区间和
{
int s=0;
while(i>0)
{
s += c[i];
i =i - lowbit(i);
}
return s;
}
int main()
{
int x,y,n;
while(scanf("%d",&n)!=EOF)
{
init(c);
init(lev);
for(int i=0;i<n;i++)
{
scanf("%d%d",&x,&y);
int temp=sum(x+1);
lev[temp]++;
add(x+1,1);
}
for(int i=0;i<n;i++)
printf("%d\n",lev[i]);
}
return 0;
}
poj2352 Stars(树状数组),布布扣,bubuko.com
标签:des style blog http color os io strong
原文地址:http://blog.csdn.net/wjw0130/article/details/38554041