题目链接:

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代码:

 #include<bits/stdc++.h>
using namespace std;
# define ll long long
# define inf 0x3f3f3f3f
const int maxn = 2e5+;
struct node
{
int num;
int ti;
int id;
node()
{
num=,ti=,id=;
}
bool friend operator < (node t1,node t2)
{
if(t1.num==t2.num&&t1.ti==t2.ti)
return t1.id<t2.id;
if(t1.num!=t2.num)
return t1.num>t2.num;
return t1.ti<t2.ti;
}
} q[maxn];
set<node>w;
int main()
{
int n,m;
scanf("%d %d",&n,&m);
// { for(int i=; i<=n; i++)
{
q[i].id=i;
}
int st,ed;
for(int i=; i<=m; i++)
{
scanf("%d %d",&st,&ed);
w.erase(q[st]);
q[st].num++;
q[st].ti+=ed;
if(st==)
{
while(!w.empty()&&(q[]<(*(--w.end() ) ) ) )
w.erase(*(--w.end()));
}
else
{
if(q[st]<q[])//注意运算符
w.insert(q[st]);
}
printf("%d\n",w.size()+);
}
return ;
}

G - Galactic Collegiate Programming Contest Kattis - gcpc (set使用)的更多相关文章

  1. Codeforces Gym101572 G.Galactic Collegiate Programming Contest (2017-2018 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2017))

    Problem G Galactic Collegiate Programming Contest 这个题题意读了一会,就是几个队参加比赛,根据实时的信息,问你1号队的实时排名(题数和罚时相同的时候并 ...

  2. Nordic Collegiate Programming Contest NCPC 2017-Problem G Galactic Collegiate Programming Contest

    题目大意:有n( n<1e5 )只队伍参加程序竞赛,然后给m个信息,每个信息告诉你第p 个队伍过了一题,并且告诉你罚时是多少,让你输入每个信息之后,第一个队伍的 排名. 思路:一眼看过去就像数据 ...

  3. 【离散化树状数组】Nordic Collegiate Programming Contest G.Galactic Collegiate Programming Contest

    #include<bits/stdc++.h> using namespace std; typedef long long ll; int n,m; ; struct node { in ...

  4. Gym - 101572G Galactic Collegiate Programming Contest 小根堆(set)

    题目传送门 题目大意: n个人,m次提交,每次提交都代表某支队伍做出一题,并且给出罚时,让你输出每次提交后,编号为1的队伍的排名. 思路: 首先处理ac和罚时,由于罚时最大1000,最多有1e5次,要 ...

  5. Galactic Collegiate Programming Contest Gym - 101572G 模拟

    #include<bits/stdc++.h> using namespace std; int n,m; struct node { int id; int slove; int pen ...

  6. 2017-2018 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2017)

    A. Airport Coffee 设$f_i$表示考虑前$i$个咖啡厅,且在$i$处买咖啡的最小时间,通过单调队列优化转移. 时间复杂度$O(n)$. #include<cstdio> ...

  7. 2017-2018 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2017) Solution

    A - Airport Coffee 留坑. B - Best Relay Team 枚举首棒 #include <bits/stdc++.h> using namespace std; ...

  8. 模拟赛小结:2017-2018 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2017)

    比赛链接:传送门 本场我们队过的题感觉算法都挺简单的,不知道为啥做的时候感觉没有很顺利. 封榜后7题,罚时1015.第一次模拟赛金,虽然是北欧的区域赛,但还是有点开心的. Problem B Best ...

  9. 2018 German Collegiate Programming Contest (GCPC 18)

    2018 German Collegiate Programming Contest (GCPC 18) Attack on Alpha-Zet 建树,求lca 代码: #include <al ...

随机推荐

  1. ThymeLeaf的eclipse插件安装

    “Help”----“Install New Software...” 输入: http://www.thymeleaf.org/eclipse-plugin-update-site/ 一路Next, ...

  2. 移动端click事件延时

    在移动端使用click事件会产生300ms的延迟 问题的产生: 移动端存在双击放大的问题,所以在移动端点击事件发生时,为了判断用户的行为(到底是要双击还是要点击),浏览器通常会等待300ms,如果30 ...

  3. Linux(centos7)如何安装Zend Optimizer Zend Guard Loader

    下载地址:http://www.zend.com/en/products/loader/downloads#Linux 1.解压 wget http://downloads.zend.com/guar ...

  4. RabbitMQ 消费者的消息确认机制

    消息确认的几点说明: 1. Basic.Ack 发回给 RabbitMQ 以告知,可以将相应 message 从 RabbitMQ 的消息缓存中移除.2. Basic.Ack 未被 consumer ...

  5. Go条件语句、switch和循环语句

    一:Go条件语句 package main import "fmt" //========go条件判断语句=== func main() { { fmt.Println(" ...

  6. RJ45连接器

    http://www.huilyn.com/path315.html      HBJ-6308ANLF http://www.hanrun.com/en/           HR971169C h ...

  7. C# 实现身份验证之WEB Service篇

    在这个WEB API横行的时代,讲WEB Service技术却实显得有些过时了,过时的技术并不代表无用武之地,有些地方也还是可以继续用他的,我之所以会讲解WEB Service,源于我最近面试时被问到 ...

  8. 非root用户ssh 执行 sudo远程机器免密钥

    非root用户ssh 执行 sudo远程机器免密钥 # 1.登陆192.168.1.10 ssh-keygen -t rsa # 一路回车 # 将公钥添加到认证文件中 cat ~/.ssh/id_rs ...

  9. python kafka

    转载:https://zhuanlan.zhihu.com/p/31731892 https://kafka-python.readthedocs.io/en/master/usage.html

  10. Centos 7最小化安装部署PostgreSQL

    安装 sh-4.2# yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-ce ...