[学习笔记]set的使用
2024-09-01 17:09:51
set默认进行升序排列,通过结构体可以改。
维护一个比主人公分数高的set 降序排列,比主人公高就进入set 比主人公低就不进去,或者在删除操作里删掉。
然后血的教训
https://blog.csdn.net/yangruibao/article/details/9040045
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+7;
struct node{
int t,val;
bool operator<(const node&c)const{
if(c.val==val){
return t<c.t;
}
else{
return val>c.val;
}
}
}s[maxn];
multiset<node>mot;
int main(){
int n,m;while(~scanf("%d%d",&n,&m)){
for(int i=0;i<=n;i++){
s[i].val=s[i].t=0;
}
for(int i=1;i<=m;++i){
int o,p;scanf("%d%d",&o,&p);
if(o==1){
s[1].t+=p;
s[1].val++;
}
else{
if(s[o]<s[1]){
mot.erase(mot.find(s[o]));
}
s[o].val++;
s[o].t+=p;
mot.insert(s[o]);
}
while (!mot.empty()&&!(*--mot.end()<s[1])){
mot.erase(--mot.end());
}
printf("%d\n",(int)mot.size()+1);
}
}
}
最新文章
- test markdown
- Retrofit学习入门
- A configuration with this name already exists
- Intelli IDEA 14.04开发版+注册码
- Codeforces Round #372 (Div. 2) A
- echarts在360中以及IE8浏览器不兼容:解决方案
- linux中的文件类型
- JSON2 源代码
- classes system in sencha touch
- 标准I/O库之格式化I/O
- window 7 C盘整理
- nginx 配置访问正则匹配
- poj 1018 Communication System_贪心
- Extjs入门-grid
- Spring BeanWrapper分析
- 【转载】C++引用详解
- CountDownLatch使用场景及分析
- javascript的初步认识
- 十分钟搞懂快速傅里叶变换(FFT)
- cesium编程入门(六)添加 3D Tiles,并调整位置,贴地
热门文章
- LIS是什么?【标本分拣】
- HashMap核心功能源码浅析
- SpringCloud学习之Ribbon使用(四)
- Python笔记_第五篇_Python数据分析基础教程_相关安装和版本查看
- winform显示、隐藏任务栏及开始菜单
- PAT Advanced 1004 Counting Leaves (30) [BFS,DFS,树的层序遍历]
- Swagger注解及参数细节的正确书写。
- 并发与高并发(八)-线程安全性-原子性-synchronized
- Python笔记_第四篇_高阶编程_高阶函数_3.sorted
- 移植sqlite