CF1330A.Dreamoon and Ranking Collection
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 a1, his place in the second round is a2, ..., his place in the n-th round is an.
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≤i≤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.
Dreamoon 是 Codeforces 比赛的忠实粉丝。
有一天,他声称:再参加两场有评分的比赛后,他就能集齐从 1 到 54 的所有名次。这真是令人惊叹!
受此启发,你提出了如下问题:
某人参加了 n 场 Codeforces 比赛。他在第 1 场比赛中的名次为 a1,在第 2 场比赛中的名次为 a2,……,在第 n 场比赛中的名次为 an。
现给定一个正整数 x(非零)。
请找出最大的 v,使得该人在再参加 x 场有评分的比赛后,能够集齐从 1 到 v 的所有名次。
换言之,你需要找出最大的 v,使得存在一种方式,在接下来的 x 场有评分比赛中取得若干名次,从而对每个 1≤i≤v,都至少存在一场(已参加或即将参加的)比赛,使得该人在该场比赛中获得第 i 名。
例如,若 n=6,x=2,且 a=[3,1,1,5,7,10],则答案为 v=5,因为如果他在接下来的两场比赛中分别获得第 2 名和第 4 名,那么他将集齐从 1 到 5 的所有名次,因此 v=5 是可达的。
输入格式
The first line contains an integer t (1≤t≤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≤n,x≤100). The second line contains n positive non-zero integers a1,a2,…,an (1≤ai≤100).
第一行包含一个整数 t(1≤t≤5),表示输入中测试用例的数量。
每个测试用例包含两行。第一行包含两个整数 n,x(1≤n,x≤100)。第二行包含 n 个正非零整数 a1,a2,…,an(1≤ai≤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≤i≤v, there will exist a contest where this person took the i-th place.
对于每个测试用例,输出一行,包含最大的 v,使得存在一种可能:在接下来的 x 场比赛中,对每个 1≤i≤v,都存在一场该选手获得第 i 名的比赛。
输入输出样例
输入#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,…,99 and place 101 on them in some order, to collect places 1,2,…,101.
第一个测试用例已在题目描述中给出。
在第二个测试用例中,该人有 100 场未来的比赛,因此他可以在这些比赛中分别取得 1,2,…,99 名以及 101 名(以某种顺序),从而收集到 1,2,…,101 这些名次。
输入解题思路,AI测评打分。不知道怎么写?