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的使用,简单题的更多相关文章

  1. PAT 1144 The Missing Number

    1144 The Missing Number (20 分)   Given N integers, you are supposed to find the smallest positive in ...

  2. PAT 1144 The Missing Number[简单]

    1144 The Missing Number(20 分) Given N integers, you are supposed to find the smallest positive integ ...

  3. [PAT] 1144 The Missing Number(20 分)

    1144 The Missing Number(20 分) Given N integers, you are supposed to find the smallest positive integ ...

  4. PAT 甲级 1144 The Missing Number (20 分)(简单,最后一个测试点没过由于开的数组没必要大于N)

    1144 The Missing Number (20 分)   Given N integers, you are supposed to find the smallest positive in ...

  5. PAT(A) 1144 The Missing Number(C)统计

    题目链接:1144 The Missing Number (20 point(s)) Description Given N integers, you are supposed to find th ...

  6. PAT 甲级 1144 The Missing Number

    https://pintia.cn/problem-sets/994805342720868352/problems/994805343463260160 Given N integers, you ...

  7. 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 ...

  8. 1144 The Missing Number (20 分)

    Given N integers, you are supposed to find the smallest positive integer that is NOT in the given li ...

  9. 1144. The Missing Number (20)

    Given N integers, you are supposed to find the smallest positive integer that is NOT in the given li ...

  10. 1144 The Missing Number

    Given N integers, you are supposed to find the smallest positive integer that is NOT in the given li ...

随机推荐

  1. Uva 10815 Andy's First Dictionary(字符串)

    题目链接:https://vjudge.net/problem/UVA-10815 题意 找出一段文本中的所有单词,以小写形式按照字典序输出. 思路 用空白符替换文本中所有非字母字符后再次读入. 代码 ...

  2. hdu4291 A Short problem

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission ...

  3. AtCoder Beginner Contest 183 E - Queen on Grid (DP)

    题意:有一个\(n\)x\(m\)的棋盘,你需要从\((1,1)\)走到\((n,m)\),每次可以向右,右下,下走任意个单位,\(.\)表示可以走,#表示一堵墙,不能通过,问从\((1,1)\)走\ ...

  4. HDU 3032 Nim or not Nim?(SG打表找规律)

    题意: 给你n堆石子,你每次只能操作一堆石子 1.拿去任意个,最少1个 2.把这一堆分成两堆,没有要求对半分 解析+代码: 1 //解题思路: 2 //对于一个给定的有向无环图,定义关于图的每个顶点的 ...

  5. jenkins:实现Jenkinsfile与Json的转换

    实现Jenkinsfile与Json的转换 目录 实现Jenkinsfile与Json的转换 方法1:使用现有的jenkins插件 参考 方法2:解析原生的jenkinsfile文件 参考 最近在做个 ...

  6. 敏捷史话(六):也许这个人能拯救你的代码 —— Robert C. Martin

    Robert C. Martin( 罗伯特·C·马丁),作为世界级软件开发大师.设计模式和敏捷开发先驱.C++ Report杂志前主编,也是敏捷联盟(Agile Alliance)的第一任主席,我们尊 ...

  7. Kubernets二进制安装(6)之部署主控节点服务--etcd

    Etcd是Kubernetes集群中的一个十分重要的组件,用于保存集群所有的网络配置和对象的状态信息. 整个kubernetes系统中一共有两个服务需要用到etcd用来协同和存储配置,分别是 网络插件 ...

  8. Kubernets二进制安装(4)之Docker安装

    注意:需要安装Docker的机器为mfyxw30.mfyxw40.mfyxw50 集群规划 主机名 角色 IP地址 mfyxw30.mfyxw.com Docker 192.168.80.30 mfy ...

  9. C# 类(3)

    方法重载 和python类似,在调用函数的时候可以指定默认参数,car("Jeep",color="red") 方法重载就是 可以定义几个同名的函数,然后带有不 ...

  10. Crontab 简单实现树莓派语音闹钟

    树莓派实验室按:这是来自 hyhmnn 的投稿.是时候关掉你的手机闹铃了,用树莓派外接一个音箱就可以 Make 一款科技感和实用性兼备的"AI 闹钟".这里用到了 Linux 的计 ...