标签:des blog http java strong art
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1541

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <map>
#define Maxx 32010
#define N 15010
int n;
int c[Maxx];
int str[N];
int Lowbit(int x)
{
return x&(-x);
}
void Update(int x)
{
while(x<=Maxx)
{
c[x]++;
x+=Lowbit(x);
}
}
int Sum(int x)
{
int s=0;
while(x>0)
{
s+=c[x];
x-=Lowbit(x);
}
return s;
}
int main()
{
int i,j,a,b;
while(scanf("%d",&n)!=EOF)
{
memset(c,0,sizeof(c));
memset(str,0,sizeof(str));
//for(i=0;i<n;i++)str[i]=0;
for(i=0; i<n; i++)
{
scanf("%d%d",&a,&b);
str[Sum(a+1)]++;
Update(a+1);
}
for(i=0; i<n; i++)
{
printf("%d\n",str[i]);
}
}
return 0;
}
hdu 1541 Stars 树状数组,布布扣,bubuko.com
标签:des blog http java strong art
原文地址:http://www.cnblogs.com/ccccnzb/p/3836598.html