sdut 3252 Lowest Unique Price
来源:互联网 发布:淘宝企业店铺要钱吗 编辑:程序博客网 时间:2024/06/06 01:17
Lowest Unique Price
Time Limit: 1000MS Memory Limit: 65536KB
Submit Statistic Discuss
Problem Description
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.
Input
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 ≤ 10^6) 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.
Output
Please print the current lowest unique price for every query (“q”). Print “none” (without quotes) if there is no lowest unique price.
Example Input
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
Example Output
none
none
4
3
2
题意:n次操作,b x,插入值为x的数。c x,删除值为x的数。q 输出出现次数为1且最小的数。
题解:set+map。
代码:
#include<iostream>#include<stdio.h>#include<stdlib.h>#include<algorithm>#include<vector>#include<cmath>#include<set>#include<map>#include<string.h>#define ll long longusing namespace std;int t,n,x;map<int,int>mp;set<int>s;char ss[100];int main(){ scanf("%d",&t); while(t--) { mp.clear(); s.clear(); scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%s",ss); if(ss[0]=='b') { scanf("%d",&x); mp[x]++; if(mp[x]==1) s.insert(x); else s.erase(x); } else if(ss[0]=='c') { scanf("%d",&x); mp[x]--; if(mp[x]==1) s.insert(x); else s.erase(x); } else { if(s.empty()) cout<<"none"<<endl; else cout<<*s.begin()<<endl; } } }}
- sdut 3252 Lowest Unique Price
- sdut 3252 Lowest Unique Price set
- Sdut 3252 Lowest Unique Price【思维+二分+树状数组】
- sdutoj 3252 Lowest Unique Price
- SDUTOJ3252---Lowest Unique Price
- 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维护特定值)
- 山东省第六届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
- SDUT 1098 Lowest Bit
- java基本框架
- Linux C 一站式学习 第一部分基础知识
- java集合知识总结
- 替换host文件配置
- AndrewNg机器学习——01
- sdut 3252 Lowest Unique Price
- Django个人网站,从开发到部署总结
- 汇编指令的学习1——ARM汇编的特点
- Oracle循环语句及例子(几种循环语句的语法)
- 关于JDBC+MySQL批量写入: 用insert values方式批量写入
- 文本处理工具
- VirtualApp沙盒基本原理
- more effective c++——Item M29 引用计数(二)带静态成员变量的rfstring类实现
- java中的volatile与atomic