zoukankan      html  css  js  c++  java
  • Galactic Collegiate Programming Contest Gym

    #include<bits/stdc++.h> 
    using namespace std;
    int n,m;
    struct node
    {
        int id;
        int slove;
        int pen;
        bool operator<(const node &b)const
        {
            //如果解决的数量和罚时都一样,就按照序号排序 
            if(slove==b.slove&&pen==b.pen)
                return id<b.id;
            //如果解决的数目不一样,就优先按照数目排序 
            if(slove!=b.slove)
                return slove>b.slove;
            //再按照罚时排序 
            return pen<b.pen;
        }
    } a[200000];
    set<node>s;
    int main()
    {
        cin>>n>>m;
        for (int i=1; i<=n; i++)
            a[i].id=i;
        for (int i=1; i<=m; i++)
        {
            int l,r;
            scanf("%d%d",&l,&r);
            //删去,更新 
            s.erase(a[l]);
            //解决数目++ 
            a[l].slove++;
            //罚时增加 
            a[l].pen+=r;
            //如果更新的是第一个队
            if(l==1)
            {
                while (!s.empty()&& (a[1] < ( *(--s.end()) )))
                    s.erase(--s.end());
            }
            else
            {
                if(a[l]<a[1])
                    s.insert(a[l]);
            }
            cout<<s.size()+1<<endl;
        }
    }
  • 相关阅读:
    HackerRank
    HackerRank
    LeetCode "Kth Smallest Element in a BST"
    HackerRank
    HackerRank
    LeetCode "Roman to Integer"
    LeetCode "Integer to Roman"
    LeetCode "Majority Element II"
    HackerRank
    HackerRank
  • 原文地址:https://www.cnblogs.com/QingyuYYYYY/p/12349642.html
Copyright © 2011-2022 走看看