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. poj 3436 ACM Computer Factory 最大流+记录路径

    题目 题意: 每一个机器有一个物品最大工作数量,还有一个对什么物品进行加工,加工后的物品是什么样.给你无限多个初始都是000....的机器,你需要找出来经过这些机器操作后最多有多少成功的机器(111. ...

  2. vs2017创建文件模板(自动添加创建信息:创建者,创建日期等信息)

    很多小伙伴在创建新的类的时候都要都要手动写类的注释,如作者名称.创建日期.版本等等,当有几个类的时候还可以手动写写,但有几十个或者更多的类的时候就麻烦了,所以我们可以设定Visual Studio 2 ...

  3. Java容器--2021面试题系列教程(附答案解析)--大白话解读--JavaPub版本

    Java容器--2021面试题系列教程(附答案解析)--大白话解读--JavaPub版本 前言 序言 再高大上的框架,也需要扎实的基础才能玩转,高频面试问题更是基础中的高频实战要点. 适合阅读人群 J ...

  4. Shell 信号处理 & Expect 免交互

    监控脚本项目 信号处理 1 什么是信号 由键盘组合键或者 kill 命令发出操作称之为信号 信号是发送给进程的,进程在收到信号后会作出默认的响应 2 为何要在进程内处理信号 进程在收到信号后会有默认的 ...

  5. woj1002-Genesis woj1003-birthofnoah woj1004-noah's ark

    title: woj1002-Genesis date: 2020-03-05 categories: acm tags: [acm,woj] 输入输出考虑一下.easy #include <i ...

  6. flagcounter 被禁用...

    源地址 https://s11.flagcounter.com/count2/arWz/bg_FFFFFF/txt_000000/border_CCCCCC/columns_2/maxflags_14 ...

  7. Leetcode(82)-删除排序链表中的重复元素 II

    给定一个排序链表,删除所有含有重复数字的节点,只保留原始链表中 没有重复出现 的数字. 示例 1: 输入: 1->2->3->3->4->4->5 输出: 1-&g ...

  8. vue & this.$copyText

    vue & this.$copyText click copy https://www.npmjs.com/package/vue-clipboard2 <p>{{message2 ...

  9. svn conflict & svn cleanup

    svn conflict & svn cleanup OK $ svn --help $ svn cleanup Tree Conflicts https://tortoisesvn.net/ ...

  10. Typescript & classes & public shorthand

    classes & public shorthand Also of note, the use of public on arguments to the constructor is a ...