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. HDU5934 Bomb(2016杭州CCPC第二题)(强连通缩点)

    Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  2. Linux驱动设计编译错误信息集锦

    1.warning: passing argument 2 of 'request_irq' from incompatible pointer type http://blog.sina.com.c ...

  3. (转) A Survival Guide to a PhD

    A Survival Guide to a PhD Sep 7, 2016 This guide is patterned after my “Doing well in your courses”, ...

  4. jquery选取iframe

    $(window).load(function(){ $('iframe').contents().find('form'); })

  5. Linux-IP地址后边加个/8(16,24,32)是什么意思?

    是掩码的位数        A类IP地址的默认子网掩码为255.0.0.0(由于255相当于二进制的8位1,所以也缩写成“/8”,表示网络号占了8位);    B类的为255.255.0.0(/16) ...

  6. vc++ mfc 里保存缩放的bmp图片 不失真

    void CSaveView::OnFileSave() { BITMAP info;//原始图片 m_bitmap.GetBitmap(&info); CDC DC1; DC1.Create ...

  7. 二十四种设计模式:装饰模式(Decorator Pattern)

    装饰模式(Decorator Pattern) 介绍动态地给一个对象添加一些额外的职责.就扩展功能而言,它比生成子类方式更为灵活.示例有一个Message实体类,某个对象对它的操作有Insert()和 ...

  8. 011. asp.net内置对象

    Response对象: Response代表了服务器响应对象, 主要用于将数据从服务器发送回浏览器; 每次客户端发出一个请求的时候,服务器就会用一个响应对象来处理这个请求,处理完这个请求之后,服务器就 ...

  9. svn安装

    方法三.无法连接网络的情况(link链接) 1.从官网下载 Site-1.6.5.zip 2.解压Site-1.6.5.zip至${eclipse}PluginsSubclipse-1.6.5.zip ...

  10. 浅析Struts1和Struts2的Action线程安全问题 转

    浅析Struts1和Struts2的Action线程安全问题  转 http://blog.csdn.net/virgoboy2004/article/details/5876133 [问题描述]最近 ...