zoukankan      html  css  js  c++  java
  • hdu 1541 Stars

    /* ***********************************************
    Author        :xryz
    Email         :523689985@qq.com
    Created Time  :4-21 21:20:06
    File Name     :a.cpp
    ************************************************ */
    
    #include <stdio.h>
    #include <string.h>
    #include <iostream>
    #include <algorithm>
    #include <vector>
    #include <queue>
    #include <set>
    #include <map>
    #include <string>
    #include <math.h>
    #include <stdlib.h>
    #include <time.h>
    using namespace std;
    
    const int N=32000+5;
    int c[N],a[N];
    
    int lowbit(int x)
    {
        return x&-x;
    }
    
    int sum(int x)
    {
        int ret=0;
        while(x>0)
        {
            ret+=c[x];
            x-=lowbit(x);
        }
        return ret;
    }
    
    void add(int x,int d)
    {
        while(x<=N)
        {
            c[x]+=d;
            x+=lowbit(x);
        }
    }
    
    int main()
    {
        int n,i,x,y,t;
        while(~scanf("%d",&n))
        {
            memset(c,0,sizeof(c));
            memset(a,0,sizeof(a));
    
            for(i=0;i<n;i++)
            {
                scanf("%d%d",&x,&y);
                add(x+1,1);
                a[sum(x+1)]++;
            }
            for(i=1;i<=n;i++)
                printf("%d
    ",a[i]);
        }
        return 0;
    }

    版权声明:本文为博主原创文章,未经博主允许不得转载。http://xiang578.top/

  • 相关阅读:
    第十二周作业
    第十二周上机练习
    第十一周作业
    第十一周上机练习
    第十周上机作业
    第九周上机练习
    第八周作业
    软件测试第一次作业
    Jsp第二次作业
    JSP第一次作业
  • 原文地址:https://www.cnblogs.com/xryz/p/4848033.html
Copyright © 2011-2022 走看看