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 ...
随机推荐
- 《2017全球人工智能人才白皮书》发布丨解读世界顶级AI牛人的秘密——腾讯研究院
<2017全球人工智能人才白皮书>发布丨解读世界顶级AI牛人的秘密——腾讯研究院:下载链接:http://www.tisi.org/c16 这个报告写的很好,排版布局,表格,色调,内容都值 ...
- 紫书 例题 10-23 UVa 10213(欧拉公式+高精度)
用欧拉公式V-E+F=2 V是顶点数,E是边数,F是面数 具体推导见https://blog.csdn.net/QWsin/article/details/53635397 要用高精度 #includ ...
- back_inserter 与 iterator
查看这里: http://www.cplusplus.com/reference/iterator/back_inserter/ 是用来在最后插入的 注意,这个函数,是隐式特化了.
- 做一个萌萌哒的button之box-shadow
接上篇:http://blog.csdn.net/u010037043/article/details/47035077 一.box-shadow box-shadow是给元素块加入周边阴影效果. b ...
- Linux 下UVC&V4L2技术简单介绍(二)
通过前文Linux 下UVC&V4L2技术简单介绍(一)我们了解了UVC和V4L2的简单知识. 这里是USB设备的文档描写叙述:http://www.usb.org/developers/do ...
- QThread 爬坑之旅(三种办法解决QObject: Cannot create children for a parent that is in a different thread)
Cannot create children for a parent that is in a different thread. 在Qt的官方文档,大家知道有两种方式使用QThread. You ...
- Ubuntu 安装软件和centos 对比命令
之前都是使用Redhat 或者Centos 等rpm的linux ,开始使用ubuntu 很不习惯 1. 安装命令Centos : yum install httpd ...
- 解决Maven项目相互依赖/循环依赖/双向依赖的问题
转自:https://blog.csdn.net/leolu007/article/details/53079875 添加新随笔很多时候随着项目的膨胀,模块会越来越多 ...
- POJ 3281 网络流
题意: 思路: 网络流 重在建图- 建完了图 就一切都好说了 这道题 我的想法是 先把源点和所有的食品连上边 (容量为1) 再把食品和对应的奶牛连上边 (容量为1) 这个时候要拆点 因为每只奶牛只能才 ...
- Java反射异常处理之InvocationTargetException
java.lang.reflect.InvocationTargetException处理办法可能是没有引commons-lang3-3.x.jar包