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 11 to 5454 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 nn Codeforces rounds. His place in the first round is a1a_1, his place in the second round is a2a_2, ..., his place in the nn-th round is ana_n.

You are given a positive non-zero integer xx.

Please, find the largest vv such that this person can collect all the places from 11 to vv after xx more rated contests.

In other words, you need to find the largest vv, such that it is possible, that after xx more rated contests, for each 1≤i≤v1 \leq i \leq v, there will exist a contest where this person took the ii-th place.

For example, if n=6n=6, x=2x=2 and a=[3,1,1,5,7,10]a=[3,1,1,5,7,10] then answer is v=5v=5, because if on the next two contest he will take places 22 and 44, then he will collect all places from 11 to 55, so it is possible to get v=5v=5.

Dreamoon 是 Codeforces 比赛的忠实粉丝。

有一天,他声称:再参加两场有评分的比赛后,他就能集齐从 11 到 5454 的所有名次。这真是令人惊叹!

受此启发,你提出了如下问题:

某人参加了 nn 场 Codeforces 比赛。他在第 11 场比赛中的名次为 a1a_1,在第 22 场比赛中的名次为 a2a_2,……,在第 nn 场比赛中的名次为 ana_n。

现给定一个正整数 xx(非零)。

请找出最大的 vv,使得该人在再参加 xx 场有评分的比赛后,能够集齐从 11 到 vv 的所有名次。

换言之,你需要找出最大的 vv,使得存在一种方式,在接下来的 xx 场有评分比赛中取得若干名次,从而对每个 1≤i≤v1 \leq i \leq v,都至少存在一场(已参加或即将参加的)比赛,使得该人在该场比赛中获得第 ii 名。

例如,若 n=6n=6,x=2x=2,且 a=[3,1,1,5,7,10]a=[3,1,1,5,7,10],则答案为 v=5v=5,因为如果他在接下来的两场比赛中分别获得第 22 名和第 44 名,那么他将集齐从 11 到 55 的所有名次,因此 v=5v=5 是可达的。

输入格式

The first line contains an integer tt (1≤t≤51 \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,xn, x (1≤n,x≤1001 \leq n, x \leq 100). The second line contains nn positive non-zero integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤1001 \leq a_i \leq 100).

第一行包含一个整数 tt(1≤t≤51 \leq t \leq 5),表示输入中测试用例的数量。

每个测试用例包含两行。第一行包含两个整数 n,xn, x(1≤n,x≤1001 \leq n, x \leq 100)。第二行包含 nn 个正非零整数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤1001 \leq a_i \leq 100)。

输出格式

For each test case print one line containing the largest vv, such that it is possible that after xx other contests, for each 1≤i≤v1 \leq i \leq v, there will exist a contest where this person took the ii-th place.

对于每个测试用例,输出一行,包含最大的 vv,使得存在一种可能:在接下来的 xx 场比赛中,对每个 1≤i≤v1 \leq i \leq v,都存在一场该选手获得第 ii 名的比赛。

输入输出样例

  • 输入#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,…,991,2,\ldots,99 and place 101101 on them in some order, to collect places 1,2,…,1011,2,\ldots,101.

第一个测试用例已在题目描述中给出。

在第二个测试用例中,该人有 100 场未来的比赛,因此他可以在这些比赛中分别取得 1,2,…,991,2,\ldots,99 名以及 101101 名(以某种顺序),从而收集到 1,2,…,1011,2,\ldots,101 这些名次。

输入解题思路,AI测评打分。不知道怎么写?

首页