307264: CF1330A. Dreamoon and Ranking Collection

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Dreamoon and Ranking Collection

题意翻译

### 题目描述 Dreamoon 热衷于参加 Codeforces 竞赛。 一天,他声称自己再参加两场 rated 场后,就会获得过从第 $1$ 名到第 $54$ 名的所有名次。这真是不可思议! 基于此,你提出了如下一个问题: 张三参加了 $n$ 场 Codeforces 比赛。他第一场的排名为 $a_1$,第二场的排名为 $a_2$,……,第 $n$ 场的排名为 $a_n$。 给出一个正整数 $x$。请找到最大的 $v$,满足张三在再参加 $x$ 场 rated 比赛后,有可能取得 $1$ 到 $v$ 中所有名次。 换句话说,你需要找到最大的 $v$,满足在继续参加 $x$ 场 rated 比赛后,有可能对于任意的 $1 \le i \le v$,存在一场张三排在第 $i$ 名的比赛。 举个例子,如果 $n = 6, x = 2, a = [3, 1, 1, 5, 7, 10]$,那么答案 $v = 5$。因为如果接下来的两次比赛内,张三分别取得了第 $2$ 名和第 $4$ 名,他可以获得过第 $1$ 名到第 $5$ 名内的所有名次,所以 $v = 5$ 是可能达成的最大答案。 ### 输入格式 第一行输入一个整数 $t ~ (1 \le t \le 5)$,表示测试数据组数。 对于每组测试数据,输入两行。 第一行输入两个整数 $n, x ~ (1 \le n, x \le 100)$。 第二行输入 $n$ 个正整数 $a_1, a_2, \ldots, a_n ~ (1 \le a_i \le 100)$。 ### 输出格式 对于每组测试数据,输出一行一个整数 $v$,表示在再参加 $x$ 次比赛后,有可能实现对于所有 $1 \le i \le v$,存在一场比赛张三排在第 $i$ 名。 ### 说明/提示 第一组测试数据的说明见【题目描述】。 对于第二组测试数据,张三将会再参加 $100$ 场比赛,他可以以任意顺序取得第 $1, 2, \ldots, 99$ 和 $101$ 名,就获得过第 $1, 2, \ldots, 101$ 名中的所有名词。

题目描述

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 $ .

输入输出格式

输入格式


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 $ ).

输出格式


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 $ .

Input

题意翻译

### 题目描述 Dreamoon 热衷于参加 Codeforces 竞赛。 一天,他声称自己再参加两场 rated 场后,就会获得过从第 $1$ 名到第 $54$ 名的所有名次。这真是不可思议! 基于此,你提出了如下一个问题: 张三参加了 $n$ 场 Codeforces 比赛。他第一场的排名为 $a_1$,第二场的排名为 $a_2$,……,第 $n$ 场的排名为 $a_n$。 给出一个正整数 $x$。请找到最大的 $v$,满足张三在再参加 $x$ 场 rated 比赛后,有可能取得 $1$ 到 $v$ 中所有名次。 换句话说,你需要找到最大的 $v$,满足在继续参加 $x$ 场 rated 比赛后,有可能对于任意的 $1 \le i \le v$,存在一场张三排在第 $i$ 名的比赛。 举个例子,如果 $n = 6, x = 2, a = [3, 1, 1, 5, 7, 10]$,那么答案 $v = 5$。因为如果接下来的两次比赛内,张三分别取得了第 $2$ 名和第 $4$ 名,他可以获得过第 $1$ 名到第 $5$ 名内的所有名次,所以 $v = 5$ 是可能达成的最大答案。 ### 输入格式 第一行输入一个整数 $t ~ (1 \le t \le 5)$,表示测试数据组数。 对于每组测试数据,输入两行。 第一行输入两个整数 $n, x ~ (1 \le n, x \le 100)$。 第二行输入 $n$ 个正整数 $a_1, a_2, \ldots, a_n ~ (1 \le a_i \le 100)$。 ### 输出格式 对于每组测试数据,输出一行一个整数 $v$,表示在再参加 $x$ 次比赛后,有可能实现对于所有 $1 \le i \le v$,存在一场比赛张三排在第 $i$ 名。 ### 说明/提示 第一组测试数据的说明见【题目描述】。 对于第二组测试数据,张三将会再参加 $100$ 场比赛,他可以以任意顺序取得第 $1, 2, \ldots, 99$ 和 $101$ 名,就获得过第 $1, 2, \ldots, 101$ 名中的所有名词。

加入题单

算法标签: