CSUOJ 1554 SG Value
1554: SG Value
Time Limit: 5 Sec Memory Limit: 256 MB
Submit: 140 Solved: 35
Description
The SG value of a set (multiset) is the minimum positive integer that could not be constituted of the number in this set.
You will be start with an empty set, now there are two opertions:
1. insert a number x into the set;
2. query the SG value of current set.
Input
Input contains multiple test cases. Each test case starts with a number N (0 < N <= 1e5) -- the total number of opertions.
The next N lines contain one opertion each.
1 x means insert a namber x into the set;
2 means query the SG value of current set.
Output
For each query output the SG value of current set.
Sample Input
5
2
1 1
2
1 1
2
Sample Output
1
2
3
HINT
Source
解题:答案爆INT啊。。。注意溢出
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
priority_queue<int,vector<int>,greater<int> >q;
int n,op;
int main(){
while(~scanf("%d",&n)){
while(!q.empty()) q.pop();
LL ans = ;
while(n--){
scanf("%d",&op);
if(op == ){
scanf("%d",&op);
q.push(op);
}else{
while(!q.empty() && q.top() <= ans + ){
ans += q.top();
q.pop();
}
printf("%lld\n",ans+);
}
}
}
return ;
}
CSUOJ 1554 SG Value的更多相关文章
- 1554: SG Value (巧妙的模拟题,也属于思维题)
1554: SG Value Submit Page Summary Time Limit: 5 Sec Memory Limit: 256 Mb Submitted: 4 ...
- CSU 1554 SG Value —— 思维
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1554 Description The SG value of a set (mult ...
- CSU 1554 SG Value (multiset/priority queue 思维题)
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1554 Description The SG value of a set (mult ...
- math --- CSU 1554: SG Value
SG Value Problem's Link: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1554 Mean: 一个可重集合,初始为空,每 ...
- csu 1554: SG Value 思维题
http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1554 这题在比赛的时候居然没想出来,然后发现居然是做过的题目的变种!!!! 先不考虑插入操作, ...
- CSU 1554 SG Value (集合类的学习)
题目大意: 2种操作 1 a:往集合中添加一个元素a 2: 询问这个集合中的元素任意组合相加所不能得到的最小数的值 这道题总是不断地去找当前所能处的最小值能否被当前的最小值加上其前部的一堆可抵达数到达 ...
- HDU 5742 Chess SG函数博弈
Chess Problem Description Alice and Bob are playing a special chess game on an n × 20 chessboard. ...
- HDU 5795 A Simple Nim 打表求SG函数的规律
A Simple Nim Problem Description Two players take turns picking candies from n heaps,the player wh ...
- HDU 1848 SG函数博弈
Fibonacci again and again Problem Description 任何一个大学生对菲波那契数列(Fibonacci numbers)应该都不会陌生,它是这样定义的:F(1 ...
随机推荐
- appium使用教程(一 环境搭建)-------------1.准备阶段
1.准备: 下载需要的安装文件等. 1) Appium(由于某种原因,官网下载会下载一半就挂掉: http://appium.io/).建议去网盘下载 2) . net framework 4.0 ...
- Decorator - 利用装饰器武装前端代码
历史 以前做后端时,接触过一点Spring,也是第一次了解DI.IOC等概念,面向切面编程,对于面向对象编程还不怎么熟练的情况下,整个人慌的一批,它的日志记录.数据库配置等都非常方便,不回侵入到业务代 ...
- python supper()函数
参考链接:https://www.runoob.com/python/python-func-super.html super() 函数是用于调用父类(超类)的一个方法. class Field(ob ...
- selenium的安装(2)
selenium的安装: 1):selenium的在线按:使用dom的cmd打开命令提示符窗口.然后敲上这个命令可以安装了==> 安装命令 pip install selenium 删除命令: ...
- ArcGIS api for javascript——用缓存区查询地图
描述 本例展示了如何在另外一个任务里使用一个任务的结果.单击地图查看被单击的点的1公里范围内的缓存(如果需要可以修改这个默认的缓存距离).也可以看缓存区的这些点的人口普查街区信息.单击一个点查看更多的 ...
- 解决Struts中文乱码问题总结
在进行struts开发的过程中.总也是出现非常多的乱码问题.但归根究竟,也仅仅是下面三种情况: ㈠页面显示中文乱码 ㈡传递參数中文乱码 ㈢国际化资源文件乱码 以下就这三中情况介绍怎么在详细项目 ...
- 一个工作快八年的老IT人士这几年沉浮总结的职场经验教训
曾经我挺喜欢写博客,认为把心中的想法表达出来非常畅快.而且还能和网上非常多人沟通交流,如今我更喜欢把想法留在心中.博客非常久没更新了,刚才闲来无事.看看职场话题版块发现非常多人都挺迷茫的,所以我写一些 ...
- jsbrige
http://www.cnblogs.com/zhangqie/p/6724252.html
- sp_executesql invalid object name
https://stackoverflow.com/questions/10417126/dynamically-named-temp-table-returns-invalid-object-nam ...
- centos7 双网卡设置(先NAT和后桥接)
摘要:VMware中搭建一台虚拟机192.168.161.5(NAT转发) 首先在VM虚拟机设置里面添加一块网卡适配器 设置为桥接模式 完成后等待自动配置 此时出现多了一个ens37 和本地网段一样的 ...