B. Alyona and Mex
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Someone gave Alyona an array containing n positive integers a1, a2, ..., an. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not apply any operation to the array at all.

Formally, after applying some operations Alyona will get an array of n positive integers b1, b2, ..., bn such that 1 ≤ bi ≤ ai for every1 ≤ i ≤ n. Your task is to determine the maximum possible value of mex of this array.

Mex of an array in this problem is the minimum positive integer that doesn't appear in this array. For example, mex of the array containing 1, 3 and 4 is equal to 2, while mex of the array containing 2, 3 and 2 is equal to 1.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of elements in the Alyona's array.

The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the elements of the array.

Output

Print one positive integer — the maximum possible value of mex of the array after Alyona applies some (possibly none) operations.

Examples
input
5
1 3 3 3 6
output
5
input
2
2 1
output
3

水题,一个数可以变成比他更小的数,问,使变完之后最大的mex数是多少。
虽然现在感觉这是水题,但比赛的时候也就只能做出A,B两题。唉,能力还要提高啊,现在大一都差不多结束了,也就这水平。不知道搞ACM还有前途没但都已经进坑了,就不能放弃啊!
话说换了一种打码的模板,感觉挺简洁的呢 ╭(╯^╰)╮
#include<bits/stdc++.h>

using namespace std;

const int INF=0x3f3f3f3f;
typedef long long ll;
#define prN printf("\n")
#define PI(a) printf("%d\n",a);
#define SI(N) scanf("%d",&(N))
#define SII(N,M) scanf("%d%d",&(N),&(M))
#define cle(a,val) memset(a,(val),sizeof(a))
#define rep(i,b) for(int i=0;i<(b);i++)
#define Rep(i,a,b) for(int i=(a);i<=(b);i++)
#define reRep(i,a,b) for(int i=(a);i>=(b);i--)
const double eps= 1e- ; /* ///////////////////////// C o d i n g S p a c e ///////////////////////// */ const int MAX_N= + ; int a[MAX_N];
int n; int main()
{
#ifndef ONLINE_JUDGE
freopen("C:\\Users\\Zmy\\Desktop\\in.txt","r",stdin);
// freopen("C:\\Users\\Zmy\\Desktop\\out.txt","w",stdout);
#endif
SI(n);
rep(i,n)
SI(a[i]);
sort(a,a+n);
int ans=;
Rep(i,,n-)
{
if (a[i]>=ans)
{
a[i]=ans;
ans++;
}
}
PI(ans);
return ;
}

Codeforces Round #358 (Div. 2)B. Alyona and Mex的更多相关文章

  1. Codeforces Round #381 (Div. 1) A. Alyona and mex 构造

    A. Alyona and mex 题目连接: http://codeforces.com/contest/739/problem/A Description Alyona's mother want ...

  2. Codeforces Round #381 (Div. 2)C. Alyona and mex(思维)

    C. Alyona and mex Problem Description: Alyona's mother wants to present an array of n non-negative i ...

  3. Codeforces Round #358 (Div. 2) E. Alyona and Triangles 随机化

    E. Alyona and Triangles 题目连接: http://codeforces.com/contest/682/problem/E Description You are given ...

  4. Codeforces Round #358 (Div. 2) D. Alyona and Strings dp

    D. Alyona and Strings 题目连接: http://www.codeforces.com/contest/682/problem/D Description After return ...

  5. Codeforces Round #358 (Div. 2) C. Alyona and the Tree 水题

    C. Alyona and the Tree 题目连接: http://www.codeforces.com/contest/682/problem/C Description Alyona deci ...

  6. Codeforces Round #358 (Div. 2) A. Alyona and Numbers 水题

    A. Alyona and Numbers 题目连接: http://www.codeforces.com/contest/682/problem/A Description After finish ...

  7. Codeforces Round #358 (Div. 2) D. Alyona and Strings 字符串dp

    题目链接: 题目 D. Alyona and Strings time limit per test2 seconds memory limit per test256 megabytes input ...

  8. Codeforces Round #358 (Div. 2) C. Alyona and the Tree dfs

    C. Alyona and the Tree time limit per test 1 second memory limit per test 256 megabytes input standa ...

  9. Codeforces Round #358 (Div. 2)——C. Alyona and the Tree(树的DFS+逆向思维)

    C. Alyona and the Tree time limit per test 1 second memory limit per test 256 megabytes input standa ...

随机推荐

  1. HDU 5513 Efficient Tree

    HDU 5513 Efficient Tree 题意 给一个\(N \times M(N \le 800, M \le 7)\)矩形. 已知每个点\((i-1, j)\)和\((i,j-1)\)连边的 ...

  2. Git连接Github

    环境:Ubuntu Server 12.04 安装Git apt-get install git git-core 配置本机Git git config --global user.name &quo ...

  3. [转]ssh常用用法小结

    ssh常用用法小结 1.连接到远程主机: 命令格式 : ssh name@remoteserver 或者 ssh remoteserver -l name 说明:以上两种方式都可以远程登录到远程主机, ...

  4. Python中变量的作用域(variable scope)

    http://www.crifan.com/summary_python_variable_effective_scope/ 解释python中变量的作用域 示例: 1.代码版 #!/usr/bin/ ...

  5. caffe 训练时,出现错误:Check failed: error == cudaSuccess (4 vs. 0) unspecified launch failure

    I0415 15:03:37.603461 27311 solver.cpp:42] Solver scaffolding done.I0415 15:03:37.603549 27311 solve ...

  6. ASM磁盘组空间不足--ORA-15041:DISGROUP DATA space exhausted (生产库案例)

    原创作品,出自 "深蓝的blog" 博客,深蓝的blog:http://blog.csdn.net/huangyanlong/article/details/47277715 近日 ...

  7. 内网渗透中的反弹Shell与端口转发

    from:https://www.91ri.org/9367.html Web渗透中的反弹Shell与端口转发 php需未禁用exec函数一:生成php反弹脚本msf > msfpayload ...

  8. 8000401a 错误 ,检索 COM 类工厂中 CLSID 为 的组件时失败,原因是出现以下错误: 8000401a。

    "/"应用程序中的服务器错误. -------------------------------------------------------------------------- ...

  9. 024. asp.net中第一次使用GridView (设置鼠标经过时更换背景色)

    1. 前端HTML代码 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Inde ...

  10. 使用JavaScript根据从后台获取来的数据打开一个新的页面

    HTML代码是: 入库类型是: <select id="selectIn" onchange="goUrl(this.options[this.selectedIn ...