Codeforces Round #358 (Div. 2) B. Alyona and Mex 水题
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 水题的更多相关文章
- Codeforces Round #358 (Div. 2) A. Alyona and Numbers 水题
A. Alyona and Numbers 题目连接: http://www.codeforces.com/contest/682/problem/A Description After finish ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #373 (Div. 2) B. Anatoly and Cockroaches 水题
B. Anatoly and Cockroaches 题目连接: http://codeforces.com/contest/719/problem/B Description Anatoly liv ...
- 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 ...
随机推荐
- java浅复制与深使用接口实现
1.浅复制与深复制概念⑴浅复制(浅克隆)被复制对象的所有变量都含有与原来的对象相同的值,而所有的对其他对象的引用仍然指向原来的对象.换言之,浅复制仅仅复制所考虑的对象,而不复制它所引用的对象. ⑵深复 ...
- 十、springcloud之Consul注销实例
@Autowired //com.ecwid.consul.v1.ConsulClient private ConsulClient consulClient; @PostMapping(" ...
- samba和SELINUX 冲突
在使用Samba进行建立Window与Linux共享时,要是不能访问,出现“您可能没有权限使用网络资源”. setsebool -P samba_enable_home_dirs on setsebo ...
- 【前端vue开发】vue项目使用sass less扩展语言所要安装的依赖
1.创建一个基于 webpack 模板的新项目 $ vue init webpack myvue 2.在当前目录下,安装依赖 $ cd myvue $ npm install 3.安装sass的依赖包 ...
- IntelliJ IDEA 把Json字符串 增加到IDE里 用windows记事本 能自动转换(自动增加转义字符)
- 关于Eclipse连接sql server 2008的若干问题
以下内容转自:https://www.cnblogs.com/skylarzhan/p/7619977.html Eclipse中使用SQL server 2008数据库 一.准备材料 要能够使用数据 ...
- 2017 MoveIt!更新 ros indigo
First MoveIt! Update in 2017. Using it on NEXTAGE pt.1 2017 MoveIt! update pt.2; Stopping motion on ...
- VS Code折腾记 - (1)扯淡
题外话 距离上篇介绍VSCode的文章已经过去四十多天,已经在正式项目作为主力开发工具了. 社区的发展非常快速,更新迭代够快,功能基本已经满足我所需了: 这个系列教程基于最新的vs code 1.8. ...
- Linux学习笔记:ps -ef、ps aux、kill -9
一.查看进程命令 1.ps命令 Linux中的ps命令是Process Status的缩写. ps命令用来列出系统中当前运行的那些进程. ps命令列出的是当前那些进程的快照,就是执行ps命令的那个时刻 ...
- java批量生成excel文件
1.导入用于操作excel的jar,地址:https://pan.baidu.com/s/1qXADRlU 2.生成excel使用的模版文件,地址:https://pan.baidu.com/s/1c ...