CodeForces 682B Alyona and Mex (题意水题)
2016-07-09 14:45
381 查看
题意:给定一个序列,你可以对这里面的数用小于它的数来代替,最后让你求,改完后的最大的序列中缺少的最小的数。
析:这个题,读了两个多小时也没读懂,要是读懂了,肯定能做出来。。。没什么可说的,就是尽量凑1 2 3 4 5。。。如果没有了,就输出。
代码如下:
析:这个题,读了两个多小时也没读懂,要是读懂了,肯定能做出来。。。没什么可说的,就是尽量凑1 2 3 4 5。。。如果没有了,就输出。
代码如下:
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int a[maxn]; int main(){ int n; while(cin >> n){ for(int i = 0; i < n; ++i) scanf("%d", &a[i]); sort(a, a+n); int cnt = 1; for(int i = 0; i < n; ++i) if(a[i] >= cnt) ++cnt; printf("%d\n", cnt); } return 0; }
相关文章推荐
- 名师对Oracle放弃Java EE的看法
- IOS开发网络数据---- AFNetworking的使用
- Velocity 变量以及转义符
- 8VC Venture Cup 2016 - Final Round (Div. 2 Edition) C. XOR Equation
- [UnityShader3]光晕效果
- Node.js模块系统
- VS2015下安装VTK7.0错误总结
- 浅谈跨域中cookie和session的联系
- Xcode调试项目时取消弹出框提示授权
- Invocation of destroy method 'close' failed on bean with name 'sqlSession'
- PDO操作MySQL 执行写操作与读操作
- 集合的补充(Map)
- mysql绿色版首次安装初始密码问题
- tensorflow
- Linux系统入门学习书籍
- 1002. A+B for Polynomials
- Android adb 命令备忘
- 7.9模拟比赛解题报告
- Thinkphp框架的源码通读1
- VS2010项目升级到VS2015时出现的问题