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

Codeforces Round #358 (Div. 2) B. Alyona and Mex 水题的更多相关文章

  1. Codeforces Round #358 (Div. 2) A. Alyona and Numbers 水题

    A. Alyona and Numbers 题目连接: http://www.codeforces.com/contest/682/problem/A Description After finish ...

  2. Codeforces Round #358 (Div. 2)B. Alyona and Mex

    B. Alyona and Mex time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  3. Codeforces Round #381 (Div. 2)B. Alyona and flowers(水题)

    B. Alyona and flowers Problem Description: Let's define a subarray as a segment of consecutive flowe ...

  4. Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题

    Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  ...

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

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

  7. Codeforces Round #290 (Div. 2) A. Fox And Snake 水题

    A. Fox And Snake 题目连接: http://codeforces.com/contest/510/problem/A Description Fox Ciel starts to le ...

  8. Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题

    A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...

  9. Codeforces Round #373 (Div. 2) B. Anatoly and Cockroaches 水题

    B. Anatoly and Cockroaches 题目连接: http://codeforces.com/contest/719/problem/B Description Anatoly liv ...

  10. Codeforces Round #368 (Div. 2) A. Brain's Photos 水题

    A. Brain's Photos 题目连接: http://www.codeforces.com/contest/707/problem/A Description Small, but very ...

随机推荐

  1. 使用ubifs格式的根文件系统

    配置内核,使其支持ubifs文件系统 1)Device Drivers  --->Memory Technology Device (MTD) support  --->UBI - Uns ...

  2. 大数据系列之分布式计算批处理引擎MapReduce实践

    关于MR的工作原理不做过多叙述,本文将对MapReduce的实例WordCount(单词计数程序)做实践,从而理解MapReduce的工作机制. WordCount: 1.应用场景,在大量文件中存储了 ...

  3. Python类相关的装饰器

    一.装饰器装饰类方法 from functools import wraps def wrapper(func): @wraps(func) def inner(self,*args,**kwargs ...

  4. Python爬取微信好友

    前言 今天看到一篇好玩的文章,可以实现微信的内容爬取和聊天机器人的制作,所以尝试着实现一遍,本文记录了实现过程和一些探索的内容 来源: 痴海 链接: https://mp.weixin.qq.com/ ...

  5. 22 Gobs of data 设计和使用采集数据的包

    Gobs of data 24 March 2011 Introduction To transmit a data structure across a network or to store it ...

  6. C# LINQ语句

    1.select 和 selectMany SelectMany() 将中间数组序列串联为一个最终结果值,其中包含每个中间数组中的每个值 2.join语句 from x in xx join d in ...

  7. python3项目之数据可视化

    数据可视化指的是通过可视化表示来探索数据,它与数据挖掘紧密相关,而数据挖掘指的是使用代码来探索数据集的规律和关联. 数据科学家使用Python编写了一系列令人印象深刻的可视化和分析工具,其中很多也可供 ...

  8. Zookeeper原理架构与搭建

    一.Zookeeper到底是什么!? 学一个东西,不搞明白他是什么东西,哪还有心情学啊!! 首先,Zookeeper是Apache的一个java项目,属于Hadoop系统,扮演管理员的角色. 然后看到 ...

  9. 编程六月定律 | 外刊IT评论网

    编程六月定律 上周,我被迫对一个很老的项目做一些修改.麻烦是,当开始着手时,我真的记不清这个项目究竟有多老了. 这实际上是我使用Codeigniter实现的第一个MVC项目.打开项目文件后,很多东西都 ...

  10. PHP array_key_exists() 函数(判断某个数组中是否存在指定的 key)

    定义和用法 array_key_exists() 函数判断某个数组中是否存在指定的 key,如果该 key 存在,则返回 true,否则返回 false. 语法 array_key_exists(ke ...