hdoj1541

9325 단어 OJ
Problem : 1541 ( Stars )     Judge Status : Accepted RunId : 2816947    Language : C++    Author : huwenbiao Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta
/***************************************************************\
*Author:Hu Wenbiao
*Created Time: Sat 14 Aug 2010 10:01:51 AM CST
*File Name: main.cpp
*Description: 。 y ,
* , x 。
\***************************************************************/

//*========================*Head File*========================*\\

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
/*----------------------*Global Variable*----------------------*/
//#define lowbit(i) i&(-i);
int C[32100],level[15100],N,x,_max;
//*=======================*Main Program*=======================*//
using namespace std;

int
lowbit(int i){
return
i&(-i);
}

int
sum(int i){
int
sum=
0;
while
(i>
0){
sum+=C[i];
i-=lowbit(i);
}

return
sum;
}

void
add(int i,int diff){
while
(i<=_max){
C[i]+=diff;
i+=lowbit(i);
}
}

int
main(){

//freopen("input","r",stdin);
_max=32001;
while
(scanf(
"%d",&N)!=EOF){
memset(C,
0,sizeof(C));
memset(level,
0,sizeof(level));
for
(int i=
0;i<N;i++){
scanf(
"%d%*d",&x);
x++;
// 1, 0 add(int i,int diff)
level[sum(x)]++;
add(x,
1);
}

for
(int i=
0;i<N;i++)
printf(
"%d
"
,level[i]);
}
}

좋은 웹페이지 즐겨찾기