1144 The Missing Number (20 分)
 

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

Input Specification:

Each input file contains one test case. For each case, the first line gives a positive integer N (≤). Then N integers are given in the next line, separated by spaces. All the numbers are in the range of int.

Output Specification:

Print in a line the smallest positive integer that is missing from the input list.

Sample Input:

10
5 -25 9 6 1 3 4 2 5 17

Sample Output:

7
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; int a[]; int main(){
int n;
cin >>n;
for(int i=;i < n;i++){
cin >> a[i];
} sort(a,a+n); int cnt = ; for(int i=;i < n;i++){
if(a[i] > ){
if(a[i]>cnt){
cout << cnt;
return ;
}
else if(a[i] == cnt){
cnt++;
}
}
}
cout << cnt; return ;
}

做水题的感觉也太棒了8

 

PAT 1144 The Missing Number的更多相关文章

  1. PAT 1144 The Missing Number[简单]

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

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

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

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

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

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

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

  5. PAT 甲级 1144 The Missing Number

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

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

  7. 1144 The Missing Number (20 分)

    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

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

随机推荐

  1. echarts 图的点击事件(含:点击重复触发的问题及其解决方法)

    今天用echarts的时候发现一个问题 鼠标指向不同地市触发一个事件展示该地区趋势图  但是但是后台中不管我第几次鼠标指向都会触发两次指向事件 现在贴出解决办法: 问题完美解决.但是为什么会调用两次, ...

  2. Oarcle之单行函数(下)

    1.字符函数 ltrim 去除字符串左边指定字符,如果不设定第二个参数,则默认去除空格 rtrim去除字符串右边指定字符,如果不设定第二个参数,则默认去除空格 例如:select ltrim (‘a  ...

  3. GRU and LSTM

    门控循环单元(GRU): 背景: 当时间步数较大或者时间步数较小的时候,循环神经网络的梯度较容易出现衰减或者爆炸.虽然裁剪梯度可以应对梯度爆炸, 但是无法解决梯度衰减的问题.正因为如此,循环神经网络在 ...

  4. JS所包含的大纲内容,以及JS中数据类型、运算符的介绍

    JavaSctipt javascript:1.特效2.表单验证 原理:何时?1.找到标签 何时?2.操作标签 写在那里? 内联(行内)(不推荐直接写js代码,经常写方法调用) 写在标签里面,以属性的 ...

  5. JZ2440学习笔记之链接文件lds

    如果在Linux环境下用arm-linux-gcc来编译arm程序,需要编写链接文件lds: 1. 运行地址=链接地址,表示代码在SDRAM中执行的地址,如果程序中有对某部分代码执行过搬运,需要在ld ...

  6. Nginx try_files 指令

    Nginx try_files 指令 按顺序检查文件是否存在,返回第一个找到的文件.结尾的斜线表示为文件夹 -$uri/.如果所有的文件都找不到,会进行一个内部重定向到最后一个参数. 务必确认只有最后 ...

  7. 【MySQL】redo log --- 刷入磁盘过程

    1.redo log基本概念 redo log的相关概念这里就不再过多阐述,网上有非常多的好的资料,可以看下缥缈大神的文章:https://www.cnblogs.com/cuisi/p/652507 ...

  8. 0x16 Tire

    参考链接:https://www.cnblogs.com/TheRoadToTheGold/p/6290732.html 题目链接:https://www.acwing.com/problem/con ...

  9. FL Studio中音频ASIO4ALL的设置

    上期我们讲解了FL Studio中音频的相关设置,今天我们来进一步讲解音频设置中的ASIO4ALL的设置,FL Studio安装包括FL Studio ASIO和第三方ASIO驱动程序ASIO4ALL ...

  10. re模块的应用

    import re # 正则表达式中的转义 : # '\(' 表示匹配小括号 # [()+*?/$.] 在字符组中一些特殊的字符会现出原形 # 所有的 \w \d \s(\n,\t, ) \W \D ...