PAT-1144(The Missing Number)set的使用,简单题
The Missing Number
PAT-1144
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<sstream>
#include<set>
using namespace std;
const int maxn=100005;
set<int>se;
int main(){
int n;
cin>>n;
for(int i=0;i<n;i++){
int a;
cin>>a;
if(a>0)
se.insert(a);
}
if(se.empty()){
cout<<1<<endl;
return 0;
}
set<int>::iterator it=se.begin();
int pre=*it;
it++;
for(;it!=se.end();it++){
int now=*it;
// cout<<now<<endl;
if(now!=pre+1){
cout<<pre+1<<endl;
return 0;
}else pre=now;
}
cout<<pre+1<<endl;
return 0;
}
PAT-1144(The Missing Number)set的使用,简单题的更多相关文章
- PAT 1144 The Missing Number
1144 The Missing Number (20 分) Given N integers, you are supposed to find the smallest positive in ...
- PAT 1144 The Missing Number[简单]
1144 The Missing Number(20 分) Given N integers, you are supposed to find the smallest positive integ ...
- [PAT] 1144 The Missing Number(20 分)
1144 The Missing Number(20 分) Given N integers, you are supposed to find the smallest positive integ ...
- PAT 甲级 1144 The Missing Number (20 分)(简单,最后一个测试点没过由于开的数组没必要大于N)
1144 The Missing Number (20 分) Given N integers, you are supposed to find the smallest positive in ...
- PAT(A) 1144 The Missing Number(C)统计
题目链接:1144 The Missing Number (20 point(s)) Description Given N integers, you are supposed to find th ...
- PAT 甲级 1144 The Missing Number
https://pintia.cn/problem-sets/994805342720868352/problems/994805343463260160 Given N integers, you ...
- PAT A1144 The Missing Number (20 分)——set
Given N integers, you are supposed to find the smallest positive integer that is NOT in the given li ...
- 1144 The Missing Number (20 分)
Given N integers, you are supposed to find the smallest positive integer that is NOT in the given li ...
- 1144. The Missing Number (20)
Given N integers, you are supposed to find the smallest positive integer that is NOT in the given li ...
- 1144 The Missing Number
Given N integers, you are supposed to find the smallest positive integer that is NOT in the given li ...
随机推荐
- 【bzoj 2339】[HNOI2011]卡农(数论--排列组合+逆元+递推)
题意:从编号为 1~N 的音阶中可选任意个数组成一个音乐片段,再集合组成音乐篇章.要求一个音乐篇章中的片段不可重复,都不为空,且出现的音符的次数都是偶数个.问组成 M 个片段的音乐篇章有多少种.答案取 ...
- 【poj 1984】&【bzoj 3362】Navigation Nightmare(图论--带权并查集)
题意:平面上给出N个点,知道M个关于点X在点Y的正东/西/南/北方向的距离.问在刚给出一定关系之后其中2点的曼哈顿距离((x1,y1)与(x2,y2):l x1-x2 l+l y1-y2 l),未知则 ...
- 牛客编程巅峰赛S1第5场 - 青铜&白银 C.排队 (优先队列,归并排序)
题意:有\(m\)个窗口,\(n\)个人排队,每个人都有各自的办理时间,只有办理完成窗口才能空出来,后面的人开始办理,求有多少人比后面的人开始办理的早但完成的晚. 题解:我们可以用优先队列来模拟办理, ...
- 4.Direct交换机之使用指定routingkey完成日志记录场景
标题 : 4.Direct交换机之使用指定routingkey完成日志记录场景 目录 : RabbitMQ 序号 : 4 const string logOthersQueueName = " ...
- bitbar 网站攻击实验
实验环境 https://github.com/TouwaErioH/security/tree/master/web1 Windows10 Oracle VM VirtualBox Ubuntu16 ...
- codefforces 877B
B. Nikita and stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inpu ...
- ThinkCMF框架任意内容包含漏洞分析复现(写入shell+文件包哈)
ThinkCMF框架任意内容包含漏洞分析复现 0x00 简介 ThinkCMF是一款基于PHP+MYSQL开发的中文内容管理框架,底层采用ThinkPHP3.2.3构建.ThinkCMF提出灵活的应用 ...
- Semantic Pull Requests All In One
Semantic Pull Requests All In One https://github.com/zeke/semantic-pull-requests docs: Update direct ...
- tree ignore & bash & cmd
tree ignore & bash & cmd tree ignore https://unix.stackexchange.com/a/47806 https://zaiste.n ...
- express+apollo+mongodb
阿波罗服务器入门 λ yarn add --dev @babel/core @babel/cli @babel/preset-env λ yarn add --dev nodemon // " ...