SDUTOJ3252---Lowest Unique Price
来源:互联网 发布:勇士vs马刺数据统计 编辑:程序博客网 时间:2024/06/06 01:57
Lowest Unique Price
Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^
借用set;
题目描述
Recently my buddies and I came across an idea! We want to build a website to sell things in a new way.
For each product, everyone could bid at a price, or cancel his previous bid, finally we sale the product to the one who offered the "lowest unique price". The lowest unique price is defined to be the lowest price that was called only once.
So we need a program to find the "lowest unique price", We'd like to write a program to process the customers' bids and answer the query of what's the current lowest unique price.
All what we need now is merely a programmer. We will give you an "Accepted" as long as you help us to write the program.
输入
The first line of input contains an integer T, indicating the number of test cases (T ≤ 60).
Each test case begins with a integer N (1 ≤ N ≤ 200000) indicating the number of operations.
Next N lines each represents an operation.
There are three kinds of operations:
"b x": x (1 ≤ x ≤ 106) is an integer, this means a customer bids at price x.
"c x": a customer has canceled his bid at price x.
"q" : means "Query". You should print the current lowest unique price.
Our customers are honest, they won\'t cancel the price they didn't bid at.
输出
Please print the current lowest unique price for every query ("q"). Print "none" (without quotes) if there is no lowest unique price.
示例输入
2 3 b 2 b 2 q 12 b 2 b 2 b 3 b 3 q b 4 q c 4 c 3 q c 2 q
示例输出
none none 4 3 2
提示
来源
示例程序
#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<queue>#include<set>#include<queue>using namespace std;const int N=1e6+10;int a[N];set<int>S;int main(){ char c[3]; int t,n,x; while(~scanf("%d",&t)) { while(t--) { scanf("%d",&n); memset(a,0,sizeof(a)); S.clear(); while(n--) { scanf("%s",c); if(c[0]=='b') { scanf("%d",&x); a[x]++; if(a[x]==1) S.insert(x); else if(a[x]==2) S.erase(x); } else if(c[0]=='c') { scanf("%d",&x); a[x]--; if(a[x]==1) { S.insert(x); } else if(a[x]==0) { S.erase(x); } } else if(c[0]=='q') { if(S.empty()) printf("none\n"); else printf("%d\n",*S.begin()); } } } } return 0;}
0 0
- SDUTOJ3252---Lowest Unique Price
- sdutoj 3252 Lowest Unique Price
- sdut 3252 Lowest Unique Price
- sdut 3252 Lowest Unique Price set
- Lowest Unique Price (第六届省赛)map
- 2015山东省赛B题-sdut3252---Lowest Unique Price
- 山东省ACM竞赛(2015)---B - Lowest Unique Price
- Lowest Unique Price 第六届ACM省赛B题
- 2015山东省第六届ACM省赛 Lowest Unique Price
- 第六届山东省ACM竞赛 B题 Lowest Unique Price
- sdut3252---Lowest Unique Price (map+set维护特定值)
- Sdut 3252 Lowest Unique Price【思维+二分+树状数组】
- 山东省第六届ACM竞赛 Lowest Unique Price(set+map)分析,总结
- Lowest Unique Price(最小且唯一价格---2015山东省省赛B题解题报告)
- 【第六届山东省ACM竞赛】B题 Lowest Unique Price(SDUT3252)
- 山东省第六届ACM大学生程序设计竞赛-Lowest Unique Price(桶排序)
- 2015年山东省第六届ACM大学生程序设计竞赛-B-Lowest Unique Price
- Latest Oakley Sunglasses Prescription Lowest Price
- J2SE大完结
- 如何写memset函数
- 树的重心 树形DP SGU 134
- 机房收费系统之优化篇
- python若干小函数的使用
- SDUTOJ3252---Lowest Unique Price
- 20150902 Java学习笔记-构造方法,关键字,封装性
- Linux套接字与虚拟文件系统(1):初始化和创建 http://www.cppblog.com/qinqing1984/archive/2015/05/03/210521.html
- android-------采用AIDL调用远程服务
- CIDR与NAT
- hdu 5417 Victor and Machine
- 【codechef】Singal Pipes(DFS求期望)
- 初始化和清除
- iOS 9.0 随机数