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 ...
随机推荐
- 配置TL-WVR45G企业路由动态地址
1.打开浏览器,在地址栏输入http://192.168.1.1. 2.输入默认用户名密码:admin,登录. 3.[基本设置]->[lan设置]->[lan设置] ip地址改成:192 ...
- scala细节
在高版本中,scala使用了自己的String,而不是java.lang.String 字符串转数字:"33.4".toDouble "33.4".toF ...
- Intel Media SDK 性能測试
经过測试,发如今windows 7上 i3 i5 上Intel Media SDK 1080P仅仅能解6路,720P仅仅能解8路, 不知大家有没有測试过?
- 3D打印技术之切片引擎(6)
[此系列文章基于熔融沉积( fused depostion modeling, FDM )成形工艺] 这一篇文章说一下填充算法中的网格填充.网格填充在现有的较为成熟的引擎中是非常普遍的:skeinfo ...
- ZOJ Problem Set - 3229 Shoot the Bullet 【有上下界网络流+流量输出】
题目:problemId=3442" target="_blank">ZOJ Problem Set - 3229 Shoot the Bullet 分类:有源有汇 ...
- 弯道超车,换一个思路,避免addEventListener为同一个元素重复赋予事件
addEventListener可以给同一个元素赋予多次同一个事件. 执行一次,就多一次事件效果.这不是我想要的. window.onload = function(){ var box = docu ...
- Redis封装之String
RedisBase类 /// <summary> /// RedisBase类,是redis操作的基类,继承自IDisposable接口,主要用于释放内存 /// </summary ...
- vue --- cli build 后的项目,图片路径出错
今天在插入背景图片过程中,遇到了路径错误的问题,通过网上查询,找到了解决的办法,但是大部分都没有讲造成这种问题的原因,故我简单地总结了一下,并加入了一些自己的理解,欢迎共同探讨~ 当用vue-cli自 ...
- 21.MFC进制转换工具
相关代码:链接:https://pan.baidu.com/s/1pKVVUZL 密码:e3vf #include <stdlib.h> #include <stdio.h> ...
- Linux下网络服务的安全设置
Linux下网络服务的安全设置 Linux操作系统由于其良好的稳定性.健壮性.高效性和安全性.正在成为各种网络服务的理想平台.各种网络应用在Linux系统上部有性能卓越的应用,例如,提供We ...