B. Alyona and Mex

题目连接:

http://www.codeforces.com/contest/682/problem/B

Description

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 every 1 ≤ 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.

Sample Input

5

1 3 3 3 6

Sample Output

5

Hint

题意

给你一个序列,然后这个序列可以交换任意两个数的位置,以及减小若干个数的大小。

然后问你这个序列的mex最大能够是多少。

题解:

排序扫一遍,太水了……

代码

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+7;
int n,a[maxn];
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
sort(a+1,a+1+n);
int level=0;
for(int i=1;i<=n;i++)
{
if(a[i]>level)
level++;
}
cout<<level+1<<endl;
}

最新文章

  1. Hibernate ManyToOne, OneToMany的理解
  2. 使用后缀数组寻找最长公共子字符串JavaScript版
  3. 双栈排序(codevs 1170)
  4. shell 命令遇到的一些问题
  5. Textview下划线注册用户跳转实现
  6. sourcetree使用问题汇总
  7. Linux Shell脚本读写XML文件
  8. 对同一元素设置overflow-x:hidden,overflow-y:visible;属性值不生效
  9. 中文变英文字母(ios)
  10. [转] HBase的特征和优点
  11. Asp.Net 控件radio 的简单使用
  12. 编程内功修炼之数据结构—BTree(一)
  13. 图片延时加载jquery.inview.js用法详解
  14. Angular 非父子组件间的service数据通信
  15. hihoCoder 1015 KMP算法
  16. Springboot项目配置druid数据库连接池,并监控统计功能
  17. python之函数对象、函数嵌套、名称空间与作用域、装饰器
  18. C#中将ListView数据导出为excel(转载)
  19. box-shadow比较美观的阴影
  20. Redis内存分析方法

热门文章

  1. linux kernel的中断子系统之(三):IRQ number和中断描述符【转】
  2. O_NONBLOCK与O_NDELAY有何不同?
  3. aarch64_m1
  4. TableView 的那些坑
  5. Focal Loss笔记
  6. go 切片的 插入、删除
  7. DevExpress CxGrid 隐藏 Drag a column header to group by that column
  8. c++实现二叉树的非递归创建以及非递归先序、中序、后序遍历
  9. MyBatis的动态插入语句(经常报‘无效的列类型’)
  10. 批处理命令篇--配置免安装mysql