CodeForces Gym 100989D 1D Cafeteria (B)
来源:互联网 发布:淘宝店铺降权处置 编辑:程序博客网 时间:2024/05/16 02:34
读懂题之后就简单很多,就是一个pair<int,int>,然后用set维护就行
#include <cstdio>#include <iostream>#include <algorithm>#include <cmath>#include <queue>#include <cstring>#include <vector>#include <set>using namespace std;#define ll long long#define maxn 100005int N, Q;int num[maxn];set< pair<int, int> > table;set< pair<int, int> >::iterator itor;int main(){//freopen("input.txt", "r", stdin);//freopen("output.txt", "w", stdout);scanf("%d%d", &N, &Q);for (int i = 1; i <= N; ++i){scanf("%d", &num[i]);table.insert(make_pair(num[i], i));}char cmd[10];int tmp;while (Q--){scanf("%s%d", cmd, &tmp);if (cmd[0] == 'i'){itor = table.lower_bound(make_pair(tmp, 0));if (itor == table.end()){printf("-1\n");}else{printf("%d\n", itor->second);table.erase(itor);}}else{table.insert(make_pair(num[tmp], tmp));}}//system("pause");//while (1);return 0;}
0 0
- CodeForces Gym 100989D 1D Cafeteria (B)
- CodeForces Gym 100989C 1D Cafeteria (A)
- 2016 Personal Training #1 Div.2 D - 1D Cafeteria (B) Gym 100989D
- CodeForces Gym 100735D
- codeforces GYM 101431D(构造)
- Codeforces Gym 101485D Debugging
- Codeforces Gym 100623D Problem D. Deposits
- CodeForces Gym 100646D Party Party Party
- Codeforces Gym 100463D Evil DFS
- codeforces Gym 100187D Holidays(排列组合)
- Codeforces gym 101102 D 单调栈
- Codeforces Gym 101234D Forest Game
- Codeforces Gym 100642 C D F
- Codeforces Gym 100342D Problem D. Dinner Problem Dp+高精度
- CodeForces Gym 100989B LCS (B)
- Codeforces Gym 100203D Different vectors 想法题 + Hash
- Codeforces GYM 100651 D I Conduit! (水计算几何)
- Codeforces Gym 100203D Different vectors 最小表示法
- 事物的隔离级别及产生的影响脏读 不可重复读 幻读
- VS2010/MFC(对话框:模态对话框及其弹出过程)
- Java IO最详解
- git提交项目到多个网站
- python,java,c,c++ 效率比较
- CodeForces Gym 100989D 1D Cafeteria (B)
- 20160714
- Eclipse中设置XML文件的自动格式化配
- C++构造函数
- 团体程序设计天梯赛-练习集L1-018. 大笨钟
- a标签设置不跳转
- 团体程序设计天梯赛-练习集L1-019. 谁先倒
- IOS可执行文件学习总结
- maven 编译后,没有生成class文件的解决方案