http://codeforces.com/problemset/problem/682/B
题意:
没看懂题目。
思路:
参考了官方的题解,引入变量 cur=1 对排序后的数组进行遍历,如果a[i] > cur -> cur++;
Code:
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MYDD=1103+1e5;
int a[MYDD];
int main() {
int n;
while(scanf("%d",&n)!=EOF) {
for(int j=0; j<n; j++)
scanf("%d",&a[j]);
int cur=1;;
sort(a,a+n);
for(int j=0; j<n; j++) {
if(a[j]>=cur) cur++;
}
printf("%d\n",cur);
}
return 0;
}
/* By:Shyazhut */