A. Next Test
链接:https://codeforces.com/problemset/problem/27/A
«Polygon» is a system which allows to create programming tasks in a simple and professional way. When you add a test to the problem, the corresponding form asks you for the test index. As in most cases it is clear which index the next test will have, the system suggests the default value of the index. It is calculated as the smallest positive integer which is not used as an index for some previously added test.
You are to implement this feature. Create a program which determines the default index of the next test, given the indexes of the previously added tests.
Input
The first line contains one integer n (1 ≤ n ≤ 3000) — the amount of previously added tests. The second line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 3000) — indexes of these tests.
Output
Output the required default value for the next test index.
Examples
input
Copy
3 1 7 2
output
Copy
3
代码:
#include<bits/stdc++.h>
using namespace std;
long long n,t,l,r,k,s,d,max1=0,b,c,mod=1e9+7;
long long a[100005];
map<long long,long long>m,p;
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>t;
m[t]++;
}
for(int i=1;i<=3001;i++)
{
if(m[i]==0)
{
cout<<i;
break;
}
}
}
上一篇: 022:迷宫问题(程序设计与算法2,广度优先搜索)
下一篇: Class类文件结构
推荐阅读
-
浅谈regExp的test方法取得的值变化的原因及处理方法
-
Win10 AV-Test的杀软大PK:Win10 Defender不再花瓶
-
On Error Resume Next 语句
-
javascript 使用正则test( )第一次是 true,第二次是false
-
Next.js项目实战踩坑指南(笔记)
-
PHP错误Parse error: syntax error, unexpected end of file in test.php on line 12解决方法
-
简述JavaScript的正则表达式中test()方法的使用
-
基于Android CALL && SendMes Test的相关介绍
-
Linux shell中的test命令用法教程
-
Shell脚本test命令使用总结和实例