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 ;
}

最新文章

  1. 企业应用开发模式 ERP项目中应用到的技术和工具
  2. [ASP.NET Web API]如何Host定义在独立程序集中的Controller
  3. JS:callee属性
  4. c++11新的小猫腻
  5. 兼容ie8 rgba()用法
  6. Jenkins Job 自杀 groovy
  7. Redis的WEB界面管理工具phpRedisAdmin
  8. CSS3关于transition过渡
  9. WPF实现3D翻转的动画效果
  10. mysql内存使用情况
  11. Arrays.toString(a)---&gt;将数组a的值转换为字符串
  12. tmux简要介绍
  13. Swift如何取得View所属的ViewController
  14. v-for 在 VSCode 中出现 Elements in iteration expect to have &#39;v-bind:key&#39; directives.
  15. 【ASP.NET Core快速入门】(一)环境安装
  16. zookeeper的单实例和伪集群部署
  17. Linux下调整ext3分区大小【转】
  18. IIS7配置伪静态把后缀名映射为html方案
  19. Python(1):入门
  20. 并发包java.util.concurrent.locks.Lock

热门文章

  1. PHP 数组转字符串,字符串转数组
  2. bzoj2763 [JLOI]飞行路线 分层图最短路
  3. head---显示文件的开头的内容
  4. [BJOI2018]求和(树链剖分)
  5. java关闭资源,自制关闭资源工具类
  6. Android-Volley网络通信框架(StringRequest &amp;amp; JsonObjectRequest)
  7. linux系统 硬链接和软链接
  8. Gym - 100338C Important Roads 最短路+tarjan
  9. NGINX 代理以及 HTTPS (一)
  10. 安装oracle常见问题分析