Gym - 101102C
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+;
int data[maxn],last[maxn],ans;
struct D {
int id;
int sc;
int time;
D(int id0=,int sc0=,int time0=){
id=id0;
sc=sc0;
time=time0;
}
};
bool operator < (D a,D b) {
if(a.sc!=b.sc) return a.sc<b.sc;
if(a.id!=b.id) return a.id>b.id;
return a.time<b.time;
}
int main()
{
int t,n,q,x,p;
scanf("%d",&t);
while(t--)
{
priority_queue<D> que;
int ansid=,anssum=,ans=;
scanf("%d%d",&n,&q);
for(int i=;i<=n;i++) que.push(D(i,,));
//printf("%d\n",que.top().id);
memset(data,,sizeof(data));
memset(last,,sizeof(last));
ans=;
int ansT=;
for(int i=;i<=q;i++)
{
scanf("%d%d",&x,&p);
data[x]+=p;
last[x]=i;
while(!que.empty() && que.top().time != last[que.top().id]) que.pop();
if(x==ans&&p<) {
//printf("%d %d---\n",ans,que.top().id);
//D tmp = que.top();
//que.pop();
while(!que.empty() && que.top().time != last[que.top().id]) que.pop();
//printf("%d %d---\n",ans,que.top().id);
if(!que.empty()&&(data[ans]<que.top().sc||(data[ans]==que.top().sc && que.top().id<ans))) {
ansT = i;
ans = que.top().id;
}
//que.push(tmp);
}
else if(p>=&&x!=ans&&(data[x]>data[ans]||(data[x]==data[ans]&&x<ans))) {
ans = x;
ansT = i;
}
que.push(D(x,data[x],i));
}
printf("%d\n",ansT);
}
return ;
}
Gym - 101102C的更多相关文章
- Gym 101102C Bored Judge(set--结构体集合)
这个故事告诉我们,WA了一定要找自己的原因... ... 当我开始用set去做的时候,发现一直过不去,一开始忘了把初始排名加进去,后来忘了第0秒,第0秒第一的id = 1 这个题目的做法也不只这一种, ...
- Gym - 101102C线段树
Judge Bahosain was bored at ACM AmrahCPC 2016 as the winner of the contest had the first rank from t ...
- ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力
Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS Memory Limit:65536KB 64bit IO Fo ...
- ACM: Gym 101047K Training with Phuket's larvae - 思维题
Gym 101047K Training with Phuket's larvae Time Limit:2000MS Memory Limit:65536KB 64bit IO F ...
- ACM: Gym 101047E Escape from Ayutthaya - BFS
Gym 101047E Escape from Ayutthaya Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I6 ...
- ACM: Gym 101047B Renzo and the palindromic decoration - 手速题
Gym 101047B Renzo and the palindromic decoration Time Limit:2000MS Memory Limit:65536KB 64 ...
- Gym 101102J---Divisible Numbers(反推技巧题)
题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...
- Gym 100917J---Judgement(01背包+bitset)
题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...
- Gym 100917J---dir -C(RMQ--ST)
题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...
随机推荐
- C#进阶系列——MEF实现设计上的“松耦合”(一)
前言:最近去了趟外地出差,介绍推广小组开发的框架类产品.推广对象是本部门在项目上面的同事——1到2年工作经验的初级程序员.在给他们介绍框架时发现很多框架设计层面的知识他们都没有接触过,甚至没听说过,这 ...
- ADC
ADC转换分为两种通道组 1.规则通道组 2.注入通道组(可打断规则通道组) 工作模式 通道模式 转换模式 复位校准 AD校准
- go 聊天室简单版总结
/* * 思路:在登录成功时将用户的id存进在线用户列表中的key value中链接的ws为空,并保存用户的信息. * 当跳转到聊天室时,将用户和聊天室链接的ws存进在线用户列表中的 * 问题:如何在 ...
- 模仿iframe框架,由分隔栏动态改变左右两侧div大小———基于jQuery
<!DOCTYPE html><html lang="zh-cn"><head> <meta charset="utf-8&qu ...
- Asp.Net MVC<三> : ASP.NET MVC 基本原理及项目创建
MVC之前的那点事儿系列 解读ASP.NET 5 & MVC6系列 MVC模拟(摘自ASP.NET MVC5框架揭秘) Asp.net中,通过HttpModule的形式定义拦截器,也就是路由表 ...
- rcync 备份命令
不写复杂的命令参数什么意思,网上一搜一大堆. 这是我用的命令: rsync -ax --progress -e "ssh -p 12345" --delete root@143.2 ...
- Select Top在七种数据库中的使用方法(包含mysql)
1. Oracle数据库 SELECT * FROM TABLE1 WHERE ROWNUM<=N 2. Infomix数据库 SELECT FIRST N * FROM TABLE1 3. D ...
- gulp打包js/css时合并成一个文件时的顺序解决
1.可以使用插进gulp-order. 2.可以这样的写法: return gulp.src(['js/common.js','js/**/*.js']) .pipe(concat('build.js ...
- Examples of MIB Variables - SNMP Tutorial
30.5 Examples of MIB Variables Versions 1 and 2 of SNMP each collected variables together in a singl ...
- java 部分注解说明(待补充)
内容 所代表的意思 @RequestMapping(params = "save") @ResponseBody 将内容或对象作为http响应正文返回,并调用适合HttpMessa ...