zoukankan      html  css  js  c++  java
  • G

    题目链接:

    G - Galactic Collegiate Programming Contest

     Kattis - gcpc 

    题目大意:当前有n个人,一共有m次提交记录,每一次的提交包括两个数,st和ed。st代表当前人的编号,ed代表总的耗费的时间,每一次提交代表这个人AC了一道题。具体的排名顺序就是先按照题目数量和提交的时间来拍的,然后每一次提交后问你当当前编号为1的人排名是多少。

    具体思路:我们把人分为两类,第一类 编号为1的人。第二类,排名大于1的人。每一次当一个人进来的时候,如果这个人是1,就看一下当前set里面的题目数量和提交时间不如1的,然后弹出,最后set里面保存的只是大于1的。如果这个人不是1,看一下他的排名是不是比1大,如果大于1,就塞进set里面。

    借鉴了学长的博客

    AC代码:

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 # define ll long long
     4 # define inf 0x3f3f3f3f
     5 const int maxn = 2e5+100;
     6 struct node
     7 {
     8     int num;
     9     int ti;
    10     int id;
    11     node()
    12     {
    13         num=0,ti=0,id=0;
    14     }
    15     bool friend operator < (node t1,node t2)
    16     {
    17         if(t1.num==t2.num&&t1.ti==t2.ti)
    18             return t1.id<t2.id;
    19         if(t1.num!=t2.num)
    20             return t1.num>t2.num;
    21         return t1.ti<t2.ti;
    22     }
    23 } q[maxn];
    24 set<node>w;
    25 int main()
    26 {
    27     int n,m;
    28   scanf("%d %d",&n,&m);
    29   //  {
    30 
    31         for(int i=1; i<=n; i++)
    32         {
    33             q[i].id=i;
    34         }
    35         int st,ed;
    36         for(int i=1; i<=m; i++)
    37         {
    38             scanf("%d %d",&st,&ed);
    39            w.erase(q[st]);
    40             q[st].num++;
    41             q[st].ti+=ed;
    42             if(st==1)
    43             {
    44                 while(!w.empty()&&(q[1]<(*(--w.end() ) ) ) )
    45                     w.erase(*(--w.end()));
    46             }
    47             else
    48             {
    49                 if(q[st]<q[1])//注意运算符
    50                     w.insert(q[st]);
    51             }
    52             printf("%d
    ",w.size()+1);
    53         }
    54     return 0;
    55 }
  • 相关阅读:
    Good Substrings CodeForces
    Watto and Mechanism Codeforces Round #291 (Div. 2)
    Codeforces Round #487 (Div. 2) A Mist of Florescence (暴力构造)
    Oulipo HDU
    POJ
    求值2 组合数公式题目
    URAL
    SCU
    【转】phpcms授课学习
    WordPress文章浏览历史插件
  • 原文地址:https://www.cnblogs.com/letlifestop/p/10649420.html
Copyright © 2011-2022 走看看