Codeforces Round #358 (Div. 2)B. Alyona and Mex
1 second
256 megabytes
standard input
standard output
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 every1 ≤ 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.
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.
Print one positive integer — the maximum possible value of mex of the array after Alyona applies some (possibly none) operations.
- 5
1 3 3 3 6
- 5
- 2
2 1
- 3
- 水题,一个数可以变成比他更小的数,问,使变完之后最大的mex数是多少。
虽然现在感觉这是水题,但比赛的时候也就只能做出A,B两题。唉,能力还要提高啊,现在大一都差不多结束了,也就这水平。不知道搞ACM还有前途没但都已经进坑了,就不能放弃啊!
话说换了一种打码的模板,感觉挺简洁的呢 ╭(╯^╰)╮
- #include<bits/stdc++.h>
- using namespace std;
- const int INF=0x3f3f3f3f;
- typedef long long ll;
- #define prN printf("\n")
- #define PI(a) printf("%d\n",a);
- #define SI(N) scanf("%d",&(N))
- #define SII(N,M) scanf("%d%d",&(N),&(M))
- #define cle(a,val) memset(a,(val),sizeof(a))
- #define rep(i,b) for(int i=0;i<(b);i++)
- #define Rep(i,a,b) for(int i=(a);i<=(b);i++)
- #define reRep(i,a,b) for(int i=(a);i>=(b);i--)
- const double eps= 1e- ;
- /* ///////////////////////// C o d i n g S p a c e ///////////////////////// */
- const int MAX_N= + ;
- int a[MAX_N];
- int n;
- int main()
- {
- #ifndef ONLINE_JUDGE
- freopen("C:\\Users\\Zmy\\Desktop\\in.txt","r",stdin);
- // freopen("C:\\Users\\Zmy\\Desktop\\out.txt","w",stdout);
- #endif
- SI(n);
- rep(i,n)
- SI(a[i]);
- sort(a,a+n);
- int ans=;
- Rep(i,,n-)
- {
- if (a[i]>=ans)
- {
- a[i]=ans;
- ans++;
- }
- }
- PI(ans);
- return ;
- }
Codeforces Round #358 (Div. 2)B. Alyona and Mex的更多相关文章
- 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 #358 (Div. 2) E. Alyona and Triangles 随机化
E. Alyona and Triangles 题目连接: http://codeforces.com/contest/682/problem/E Description You are given ...
- Codeforces Round #358 (Div. 2) D. Alyona and Strings dp
D. Alyona and Strings 题目连接: http://www.codeforces.com/contest/682/problem/D Description After return ...
- Codeforces Round #358 (Div. 2) C. Alyona and the Tree 水题
C. Alyona and the Tree 题目连接: http://www.codeforces.com/contest/682/problem/C Description Alyona deci ...
- 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) D. Alyona and Strings 字符串dp
题目链接: 题目 D. Alyona and Strings time limit per test2 seconds memory limit per test256 megabytes input ...
- Codeforces Round #358 (Div. 2) C. Alyona and the Tree dfs
C. Alyona and the Tree time limit per test 1 second memory limit per test 256 megabytes input standa ...
- Codeforces Round #358 (Div. 2)——C. Alyona and the Tree(树的DFS+逆向思维)
C. Alyona and the Tree time limit per test 1 second memory limit per test 256 megabytes input standa ...
随机推荐
- JS中的call()方法的理解
fn.call(obj,arg1,arg2);这是call()方法的使用形式,apply()是差不多的.作用是用obj对象来替换fn中的this 举个栗子: function A(){ this.co ...
- [POI 2008][BZOJ 1132]Tro
这题我真是无能为力了 这题的做法还是挺简单的 枚举左下角的点做为原点,把其余点按极角排序 PS.是作为原点,如枚举到 k 时,对于所有 p[i] (包括p[k]) p[i]-=p[k] (此处为 ...
- Analyzing The Papers Behind Facebook's Computer Vision Approach
Analyzing The Papers Behind Facebook's Computer Vision Approach Introduction You know that company c ...
- 关于CPU Cache -- 程序猿需要知道的那些事
本文将介绍一些作为程序猿或者IT从业者应该知道的CPU Cache相关的知识 文章欢迎转载,但转载时请保留本段文字,并置于文章的顶部 作者:卢钧轶(cenalulu) 本文原文地址:http://ce ...
- jquery 自动补全控件(支持IE6)待整理
自动补全控件(兼容IE6):http://bassistance.de/ download地址:http://jquery.bassistance.de/autocomplete/jquery.aut ...
- 怎么用ABBYY将PDF转换为JPEG图像
FineReader Mac版,全称ABBYY FineReader Pro for Mac,是一款流行的OCR图文识别软件,可快速方便地将扫描纸质文档.PDF文件和数码相机的图像转换成可编辑.可搜索 ...
- Code First 约定
Code First 约定 借助 Code First,可通过使用 C# 或 Visual Basic .NET 类来描述模型.模型的基本形状可通过约定来检测.约定是规则集,用于在使用 Code Fi ...
- 使用JavaScript根据从后台获取来的数据打开一个新的页面
HTML代码是: 入库类型是: <select id="selectIn" onchange="goUrl(this.options[this.selectedIn ...
- Web前端开发笔试&面试_03
WL: 1.如何显示.隐藏一个dom对象? 2.如何将一个网页中的内容水平置中?写出重要的html标签和css. (css:#content{align:center;float:left;}html ...
- Google Proposes to Enhance JSON with Jsonnet
Google has open sourced Jsonnet, a configuration language that supersedes JSON and adds new features ...