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. Python伊始——From Boring to Amazing

    先来谈一下关于Python编程语言的浅薄认知,“一门编程课,仅此而已”这是我几个月前对这门应用技术的认识. 如今看来,却不只是“仅此而已”,作为今年年初被加入计算机二级考试科目的这门技术,或许并不是它 ...

  2. Mysql 版本号、存储引擎、索引查询

    [1]Mysql 版本号.存储引擎.索引查询 # 查看数据库版本号 SELECT VERSION(); # 查看数据库支持的引擎(默认即Support == DEFAULT行) SHOW ENGINE ...

  3. 同事问如何判断同花顺,我用javascript的二维数组写了个简易demo

    有个前同事在群里问如何判断是否为同花顺我用javascript的二维数组写了个简易demo. <!DOCTYPE html> <html> <body> <s ...

  4. was系统的远程调试

    1.进入websphere页面 2.servers->server types->websphere application servers->点击Additional Proper ...

  5. 第一章 Python程序语言简介

    第一节 Python概述 1. 什么是Python Python是一种 解释型.面向对象.动态数据类型 的高级程序设计语言.由Guido van Rossum与1989年发明,第一个公开发行版本发行于 ...

  6. iOS进阶之TCP代理鉴权过程

    这段时间接触了网络代理,而自己的任务是完成TCP和UDP的网络代理,所以在这里写些自己的理解吧. 这篇文章先介绍一下TCP代理的鉴权过程(采用的是用户名和密码鉴权),下一篇文章再介绍UDP代理的鉴权过 ...

  7. iOS进阶之如何进行 HTTP Mock(转载)

    这篇文章会对 OHHTTPStubs 源代码的分析,其实现原理是建立在 NSURLProtocol 的基础上的,对这部分内容不了解的读者,可以阅读这篇文章 iOS 开发中使用 NSURLProtoco ...

  8. Linux笔记 #10# 用于支持Web应用开发&部署&配置的一些自定义脚本

    索引 一.本地开发与测试相关脚本 1.startup.sh 2.shutdown.sh 3.catalina-out.sh 4.localhost_access_log.sh 5.上传本地文件到服务器 ...

  9. 还原真实,javascript之预编译 / 预解析

    今天在群里吹水时,有群友提出一个问题.我一看很简单,就立马给出了答案:因为存在变量提升,所以输出undefined.本以为无人反驳,可确招来口诛笔伐.作为写实派的我,一贯以来坚持真实是我的使命,岂能容 ...

  10. HTTP之gRPC

    gRPC 官方文档 gRPC 是一个高性能.开源和通用的 RPC 框架,面向移动和 HTTP/2 设计. gRPC 基于 HTTP/2 标准设计,带来诸如双向流.流控.头部压缩.单 TCP 连接上的多 ...