CSUOJ 1554 SG Value
2024-08-31 16:18:03
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 ;
}
最新文章
- 企业应用开发模式 ERP项目中应用到的技术和工具
- [ASP.NET Web API]如何Host定义在独立程序集中的Controller
- JS:callee属性
- c++11新的小猫腻
- 兼容ie8 rgba()用法
- Jenkins Job 自杀 groovy
- Redis的WEB界面管理工具phpRedisAdmin
- CSS3关于transition过渡
- WPF实现3D翻转的动画效果
- mysql内存使用情况
- Arrays.toString(a)--->;将数组a的值转换为字符串
- tmux简要介绍
- Swift如何取得View所属的ViewController
- v-for 在 VSCode 中出现 Elements in iteration expect to have &#39;v-bind:key&#39; directives.
- 【ASP.NET Core快速入门】(一)环境安装
- zookeeper的单实例和伪集群部署
- Linux下调整ext3分区大小【转】
- IIS7配置伪静态把后缀名映射为html方案
- Python(1):入门
- 并发包java.util.concurrent.locks.Lock
热门文章
- PHP 数组转字符串,字符串转数组
- bzoj2763 [JLOI]飞行路线 分层图最短路
- head---显示文件的开头的内容
- [BJOI2018]求和(树链剖分)
- java关闭资源,自制关闭资源工具类
- Android-Volley网络通信框架(StringRequest &;amp; JsonObjectRequest)
- linux系统 硬链接和软链接
- Gym - 100338C Important Roads 最短路+tarjan
- NGINX 代理以及 HTTPS (一)
- 安装oracle常见问题分析