A13272 | Dreamoon and Ranking Collection
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Dreamoon is a big fan of the Codeforces contests.
One day, he claimed that he will collect all the places from $1$ to $54$ after two more rated contests. It's amazing!
Based on this, you come up with the following problem:
There is a person who participated in $n$ Codeforces rounds. His place in the first round is $a_1$ , his place in the second round is $a_2$ , ..., his place in the $n$ -th round is $a_n$ .
You are given a positive non-zero integer $x$ .
Please, find the largest $v$ such that this person can collect all the places from $1$ to $v$ after $x$ more rated contests.
In other words, you need to find the largest $v$ , such that it is possible, that after $x$ more rated contests, for each $1 \leq i \leq v$ , there will exist a contest where this person took the $i$ -th place.
For example, if $n=6$ , $x=2$ and $a=[3,1,1,5,7,10]$ then answer is $v=5$ , because if on the next two contest he will take places $2$ and $4$ , then he will collect all places from $1$ to $5$ , so it is possible to get $v=5$ .
One day, he claimed that he will collect all the places from $1$ to $54$ after two more rated contests. It's amazing!
Based on this, you come up with the following problem:
There is a person who participated in $n$ Codeforces rounds. His place in the first round is $a_1$ , his place in the second round is $a_2$ , ..., his place in the $n$ -th round is $a_n$ .
You are given a positive non-zero integer $x$ .
Please, find the largest $v$ such that this person can collect all the places from $1$ to $v$ after $x$ more rated contests.
In other words, you need to find the largest $v$ , such that it is possible, that after $x$ more rated contests, for each $1 \leq i \leq v$ , there will exist a contest where this person took the $i$ -th place.
For example, if $n=6$ , $x=2$ and $a=[3,1,1,5,7,10]$ then answer is $v=5$ , because if on the next two contest he will take places $2$ and $4$ , then he will collect all places from $1$ to $5$ , so it is possible to get $v=5$ .
输入格式
The first line contains an integer $t$ ( $1 \leq t \leq 5$ ) denoting the number of test cases in the input.
Each test case contains two lines. The first line contains two integers $n, x$ ( $1 \leq n, x \leq 100$ ). The second line contains $n$ positive non-zero integers $a_1, a_2, \ldots, a_n$ ( $1 \leq a_i \leq 100$ ).
Each test case contains two lines. The first line contains two integers $n, x$ ( $1 \leq n, x \leq 100$ ). The second line contains $n$ positive non-zero integers $a_1, a_2, \ldots, a_n$ ( $1 \leq a_i \leq 100$ ).
输出格式
For each test case print one line containing the largest $v$ , such that it is possible that after $x$ other contests, for each $1 \leq i \leq v$ , there will exist a contest where this person took the $i$ -th place.
输入输出样例
输入 #1
5 6 2 3 1 1 5 7 10 1 100 100 11 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 57 80 60 40 20
输出 #1
5 101 2 2 60
The first test case is described in the statement.
In the second test case, the person has one hundred future contests, so he can take place $1,2,\ldots,99$ and place $101$ on them in some order, to collect places $1,2,\ldots,101$ .
In the second test case, the person has one hundred future contests, so he can take place $1,2,\ldots,99$ and place $101$ on them in some order, to collect places $1,2,\ldots,101$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted