CodeForces - 682B 题意水题
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.
求更改后数列中没有的最小整数,不知更改,只能求最大可能
构成1 2 3 4.。
对于5 6 7 1 2 3
#include "cstdio"
#include "iostream"
#include "string"
#include "cstring"
#include "cmath"
#include "vector"
#include "map"
#include "algorithm"
using namespace std;
int a[];
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i=;i<n;i++)
{
scanf("%d",&a[i]);
}
sort(a,a+n);
int min1=;
for(int i=;i<n;i++)
if(a[i]>min1)//可改
++min1;///最大可能+1
printf("%d\n",min1+);
}
}
CodeForces - 682B 题意水题的更多相关文章
- CodeForces 705A Hulk (水题)
题意:输入一个 n,让你输出一行字符串. 析:很水题,只要判定奇偶性,输出就好. 代码如下: #pragma comment(linker, "/STACK:1024000000,10240 ...
- Codeforces数据结构(水题)小结
最近在使用codeblock,所以就先刷一些水题上上手 使用codeblock遇到的问题 1.无法进行编译-------从setting中的编译器设置中配置编译器 2.建立cpp后无法调试------ ...
- CodeForces 682B Alyona and Mex (题意水题)
题意:给定一个序列,你可以对这里面的数用小于它的数来代替,最后让你求,改完后的最大的序列中缺少的最小的数. 析:这个题,读了两个多小时也没读懂,要是读懂了,肯定能做出来...没什么可说的,就是尽量凑1 ...
- CodeForces 705B (训练水题)
题目链接:http://codeforces.com/problemset/problem/705/B 题意略解: 两个人玩游戏,解数字,一个数字可以被分成两个不同或相同的数字 (3可以解成 1 2) ...
- codeforces 377A. Puzzles 水题
A. Puzzles Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/33 ...
- CodeForces 474B Worms (水题,二分)
题意:给定 n 堆数,然后有 m 个话询问,问你在哪一堆里. 析:这个题是一个二分题,但是有一个函数,可以代替写二分,lower_bound. 代码如下: #include<bits/stdc+ ...
- codeforces hungry sequence 水题
题目链接:http://codeforces.com/problemset/problem/327/B 这道题目虽然超级简单,但是当初我还真的没有想出来做法,囧,看完别人的代码恍然大悟. #inclu ...
- CodeForces 709A Juicer (水题, 模拟)
题意:给定 n 个桔子的大小,一个杯子的容积,一个最大限度,挨着挤桔子汁,如果大小大于限度,扔掉,如果不杯子满了倒掉,问你要倒掉多少杯. 析:直接按要求模拟就好,满了就清空杯子. 代码如下: #pra ...
- CodeForces 707B Bakery (水题,暴力,贪心)
题意:给定n个城市,其中有k个有仓库,问你在其他n-k个城市离仓库的最短距离是多少. 析:很容易想到暴力,并且要想最短,那么肯定是某一个仓库和某一个城市直接相连,这才是最优,所以只要枚举仓库,找第一个 ...
随机推荐
- 2,PyAudio 实现录音 自动化交互实现问答
Python 很强大其原因就是因为它庞大的三方库 , 资源是非常的丰富 , 当然也不会缺少关于音频的库 关于音频, PyAudio 这个库, 可以实现开启麦克风录音, 可以播放音频文件等等,此刻我们不 ...
- thrift服务端到客户端开发简单示例
(1)首先我们在服务器端写个helloworld.thrift文件,如下所示: service HelloWorld{ string ping(1: string name), string getp ...
- ubuntu开启crontab日志
今天发现Ubuntu的/var/log下没有cron日志,用下面的命令即可开启: -default.conf cron.* /var/log/cron.log #将cron前 ...
- Selenium八大元素定位方式
1.根据id来定位: import org.openqa.selenium.By;import org.openqa.selenium.WebDriver;import org.openqa.sele ...
- Lua工具类
1.打印table --一个用以打印table的函数 function print_r (t, name) print(pr(t,name)) end function pr (t, name, in ...
- Python 学习笔记之 Numpy 库——文件操作
1. 读写 txt 文件 a = list(range(0, 100)) a = np.array(a) # a.dtype = np.int64 np.savetxt("filename. ...
- Cassandra 常见错误索引
类型错误 类型错误调试的技巧 有时候,类型错误提示比较不友好,比如不知道哪个字段出错. 在php中可以用 //过滤几个数据进行操作,逐个检查,或者折半查找错误 $data = array_splice ...
- hadoop自定义数据类型
统计某手机数据库的每个手机号的上行数据包数量和下行数据包数量 数据库类型如下: 数据库内容如下: 下面自定义类型SimLines,类似于平时编写的model import java.io.DataIn ...
- Chromium之工程依赖关系.
Chromium各版本可能有差异,我的版本是chromium.r197479,2013/08前后下载的source code. Visual Studio Ultimate版本有工具可以自动生成项目依 ...
- Hibernate常用方法之_查询
1.使用session的get方法 public User getUser(int id){ Session session = null; User user = null; try { sessi ...