1 second
256 megabytes
standard input
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.
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.
Print one positive integer — the maximum possible value of mex of the array after Alyona applies some (possibly none) operations.
5
1 3 3 3 6
5
2
2 1
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 ;
}