The Missing Number

PAT-1144

  1. #include<iostream>
  2. #include<cstring>
  3. #include<string>
  4. #include<algorithm>
  5. #include<cstdio>
  6. #include<sstream>
  7. #include<set>
  8. using namespace std;
  9. const int maxn=100005;
  10. set<int>se;
  11. int main(){
  12. int n;
  13. cin>>n;
  14. for(int i=0;i<n;i++){
  15. int a;
  16. cin>>a;
  17. if(a>0)
  18. se.insert(a);
  19. }
  20. if(se.empty()){
  21. cout<<1<<endl;
  22. return 0;
  23. }
  24. set<int>::iterator it=se.begin();
  25. int pre=*it;
  26. it++;
  27. for(;it!=se.end();it++){
  28. int now=*it;
  29. // cout<<now<<endl;
  30. if(now!=pre+1){
  31. cout<<pre+1<<endl;
  32. return 0;
  33. }else pre=now;
  34. }
  35. cout<<pre+1<<endl;
  36. return 0;
  37. }

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. 【bzoj 2339】[HNOI2011]卡农(数论--排列组合+逆元+递推)

    题意:从编号为 1~N 的音阶中可选任意个数组成一个音乐片段,再集合组成音乐篇章.要求一个音乐篇章中的片段不可重复,都不为空,且出现的音符的次数都是偶数个.问组成 M 个片段的音乐篇章有多少种.答案取 ...

  2. 【poj 1984】&【bzoj 3362】Navigation Nightmare(图论--带权并查集)

    题意:平面上给出N个点,知道M个关于点X在点Y的正东/西/南/北方向的距离.问在刚给出一定关系之后其中2点的曼哈顿距离((x1,y1)与(x2,y2):l x1-x2 l+l y1-y2 l),未知则 ...

  3. 牛客编程巅峰赛S1第5场 - 青铜&白银 C.排队 (优先队列,归并排序)

    题意:有\(m\)个窗口,\(n\)个人排队,每个人都有各自的办理时间,只有办理完成窗口才能空出来,后面的人开始办理,求有多少人比后面的人开始办理的早但完成的晚. 题解:我们可以用优先队列来模拟办理, ...

  4. 4.Direct交换机之使用指定routingkey完成日志记录场景

    标题 : 4.Direct交换机之使用指定routingkey完成日志记录场景 目录 : RabbitMQ 序号 : 4 const string logOthersQueueName = " ...

  5. bitbar 网站攻击实验

    实验环境 https://github.com/TouwaErioH/security/tree/master/web1 Windows10 Oracle VM VirtualBox Ubuntu16 ...

  6. codefforces 877B

    B. Nikita and stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inpu ...

  7. ThinkCMF框架任意内容包含漏洞分析复现(写入shell+文件包哈)

    ThinkCMF框架任意内容包含漏洞分析复现 0x00 简介 ThinkCMF是一款基于PHP+MYSQL开发的中文内容管理框架,底层采用ThinkPHP3.2.3构建.ThinkCMF提出灵活的应用 ...

  8. Semantic Pull Requests All In One

    Semantic Pull Requests All In One https://github.com/zeke/semantic-pull-requests docs: Update direct ...

  9. tree ignore & bash & cmd

    tree ignore & bash & cmd tree ignore https://unix.stackexchange.com/a/47806 https://zaiste.n ...

  10. express+apollo+mongodb

    阿波罗服务器入门 λ yarn add --dev @babel/core @babel/cli @babel/preset-env λ yarn add --dev nodemon // " ...