博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #358 (Div. 2) B. Alyona and Mex 水题
阅读量:4551 次
发布时间:2019-06-08

本文共 1700 字,大约阅读时间需要 5 分钟。

B. Alyona and Mex

题目连接:

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
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<
<

转载于:https://www.cnblogs.com/qscqesze/p/5595681.html

你可能感兴趣的文章
7.内部类(一)之详解内部类
查看>>
1.messager消息提示框
查看>>
[PY]进制转换
查看>>
STL系列 list
查看>>
匿名方法和Lambda表达式
查看>>
京东的核心业务
查看>>
读书笔记(六)--成交
查看>>
Secret Number hdu 2113
查看>>
软件架构(体系结构,Architecture)和软件框架
查看>>
阶梯博弈(没怎么搞懂)
查看>>
python request post请求body中有json数组
查看>>
IDT hook KiTrap03
查看>>
字节对齐
查看>>
使用Python SocketServer快速实现多线程网络服务器
查看>>
离散数学
查看>>
外观模式理解和示例
查看>>
IDEA远程仓库版本回滚
查看>>
C++矩阵库 Eigen 简介(转载)
查看>>
sklearn的train_test_split()各函数参数含义解释(非常全)
查看>>
机器学习算法的整体流程(非常易懂)
查看>>