posts - 16,comments - 0,trackbacks - 0
# include  < stdio.h >

int  a[ 32005 ], le[ 15005 ], n;
/* ********************************************************* */
int  getsum( int  x)
{
                
int  ret  =   0 ;
                
while  (x  >   0 ) ret  +=  a[x], x  -=  (x & ( - x));
                
return  ret;
}
void  inc( int  x)
{
                
while  (x  <=   32005 ++  a[x], x  +=  (x & ( - x));
}
/* ********************************************************* */
int  main()
{
                
int  i, x, y;
                scanf(
" %d " & n);
                
for  (i  =   0 ; i  <  n;  ++ i)
                {
                                scanf(
" %d%d " & x,  & y),  ++ x;
                                
++  le[getsum(x)];
                                inc(x);
                }
                
for  (i  =   0 ; i  <  n;  ++ i) printf( " %d\n " , le[i]);

                
return   0 ;
}
posted on 2012-09-02 10:21 yajunw 阅读(137) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理