Codeforces 639A (set 水~)
来源:互联网 发布:超市库存软件 编辑:程序博客网 时间:2024/05/22 06:38
题意:每次显示不能超过k个人,当一个友情值更高的人上线时如果会替换掉当前显示的最小的友情值低于他
的人.2表示询问某个编号的人是不是正在被显示.
用一个set模拟就好了
#include <bits/stdc++.h>using namespace std;#define maxn 151111int n, k, q, t[maxn];struct node { int t, id; bool operator < (const node &a) const { return t < a.t; }}p[maxn];bool vis[maxn];set <node> gg;set <node>::iterator it;int main () { //freopen ("in.txt", "r", stdin); while (cin >> n >> k >> q) { for (int i = 1; i <= n; i++) { cin >> p[i].t; p[i].id = i; } gg.clear (); memset (vis, 0, sizeof vis); while (q--) { int id, op; cin >> op >> id; if (op == 1) { if (gg.size () < k) { gg.insert (p[id]); vis[p[id].id] = 1; } else { it = gg.begin (); node cur = (*it); if (cur.t < p[id].t) { gg.erase (cur); vis[cur.id] = 0; gg.insert (p[id]); vis[p[id].id] = 1; } } } else { if (vis[id]) cout << "YES\n"; else cout << "NO\n"; } } } return 0;}
0 0
- Codeforces 639A (set 水~)
- CodeForces 274A k-Multiple Free Set
- Codeforces 274A k-Multiple Free Set
- Codeforces#302-A. Set of Strings-水题
- CodeForces 544A Set of Strings
- 【CodeForces】[274A]k-Multiple Free Set
- codeforces 274A k-Multiple Free Set
- CodeForces - 274A - k-Multiple Free Set
- CodeForces 274 A. k-Multiple Free Set
- codeforces-752【A找规律】【set+pair】
- Codeforces 5A Chat Servers Outgoing Traffic set的使用
- CodeForces 356A - Knight Tournament set or 线段树
- Codeforces Round #302 (Div. 2) A. Set of Strings
- Codeforces Round #302 (Div. 2) A. Set of Strings
- codeforces 274A. k-Multiple Free Set【二分】
- CodeForces 274A k-Multiple Free Set (二分)
- CodeForces 274A k-Multiple Free Set【思维】
- CodeForces 639 A
- 《javascript Dom编程艺术》学习笔记
- Shell逐行读取文件的4种方法
- android Palette调色板的使用方法
- Python伪装浏览器爬虫读取网页内容
- Android小记:编码命名规范
- Codeforces 639A (set 水~)
- API。Spark SQL 1.3.0 DataFrame介绍、使用及提供了些完整的数据写入
- [简易]中英文混合排序
- Linux系统下创建任务,对指定目录文件进行自动压缩存档
- 深入探讨ROP 载荷分析
- ionic(angularjs)select下拉选择第一个选项为空白的解决办法
- POJ1700
- 读懂这100篇论文,你也能成为大数据专家
- leetcode-001-two sum-python