题目链接

#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的更多相关文章

  1. Gym 101102C Bored Judge(set--结构体集合)

    这个故事告诉我们,WA了一定要找自己的原因... ... 当我开始用set去做的时候,发现一直过不去,一开始忘了把初始排名加进去,后来忘了第0秒,第0秒第一的id = 1 这个题目的做法也不只这一种, ...

  2. Gym - 101102C线段树

    Judge Bahosain was bored at ACM AmrahCPC 2016 as the winner of the contest had the first rank from t ...

  3. 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 ...

  4. ACM: Gym 101047K Training with Phuket's larvae - 思维题

     Gym 101047K Training with Phuket's larvae Time Limit:2000MS     Memory Limit:65536KB     64bit IO F ...

  5. ACM: Gym 101047E Escape from Ayutthaya - BFS

    Gym 101047E Escape from Ayutthaya Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I6 ...

  6. ACM: Gym 101047B Renzo and the palindromic decoration - 手速题

     Gym 101047B  Renzo and the palindromic decoration Time Limit:2000MS     Memory Limit:65536KB     64 ...

  7. Gym 101102J---Divisible Numbers(反推技巧题)

    题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...

  8. Gym 100917J---Judgement(01背包+bitset)

    题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...

  9. Gym 100917J---dir -C(RMQ--ST)

    题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...

随机推荐

  1. 为什么目前没有"成熟"的cookie插件?

    一.序言 最近真是挺忙的啊,导致也挺久没有时间来看看园中各位大神的文章,只能感慨业务真尼玛的多,所以在此写下一篇文章来大话最近工作和学习上面的一点点收获体会,希望大家能够有所收获,这篇文章虽然说是一篇 ...

  2. 【原】关于使用sklearn进行数据预处理 —— 归一化/标准化/正则化

    一.标准化(Z-Score),或者去除均值和方差缩放 公式为:(X-mean)/std  计算时对每个属性/每列分别进行. 将数据按期属性(按列进行)减去其均值,并处以其方差.得到的结果是,对于每个属 ...

  3. go 数据类型转换

    使用strconv 包 首先需要import strconv包 //string to int i,err := strconv.Atoi(str) // string to int64 i64,er ...

  4. 推公式 HDU 2552

    T 给你2个值 求另外一个 需要推一下 tan(a+b)=(tan(a)+tan(b))/(1-tan(a)*tan(b)); 等式左右取tan tan(atan(a))=a 1/s=tan(...) ...

  5. C# 6.0 新特性

    1.C# 6.0 示例 1: 自动属性支持初始化, 字符串嵌入的新方式, 通过 Using Static 引用静态类, nameof 表达式CSharp6/Demo1.xaml.cs /* * C# ...

  6. offsetHeight, clientHeight与scrollHeight的区别

      在网上搜了一下,结论非常笼统,讲IE从不讲版本,因此自己做了测试并上传结论.以下结论皆是在标准模式下测试通过的,没有测试quirk模式. clientHeight 大部分浏览器对 clientHe ...

  7. 冰冻三尺非一日之寒--rabbitMQ,redis

    第11章 1.rabbitMQ   2. redis 一.rabbitMQ: 人们写了有好多好多的开源的MQ服务器.其中大多数都是写出来用来解决特定问题的.它们不关心上面跑的是什么类型的消息,设计思想 ...

  8. 解决:Linux版百度云客户端 BCloud网络错误 问题

    国内很多云盘渐渐停止服务支持,如新浪.华为.115.360等... 强大的百度云,你会继续免费让大家使用吗? 今天在Linux上使用了liulang的BCloud百度云客户端,登陆之后不显示主页,什么 ...

  9. [日常训练]yayamao的神题

    Description $yayamao$是数学神犇,一天他在纸上计算起了$1/P$, 我们知道按照模拟除法可以得到准确解,例如$1/7=0.(142857),1/10=0.1(0)$.$yayama ...

  10. Bzoj1176 [Balkan2007]Mokia

    Time Limit: 30 Sec  Memory Limit: 162 MBSubmit: 2000  Solved: 890 Description 维护一个W*W的矩阵,初始值均为S.每次操作 ...