CF1852A.Ntarsis' Set
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Ntarsis has been given a set S , initially containing integers 1,2,3,…,101000 in sorted order. Every day, he will remove the a1 -th, a2 -th, … , an -th smallest numbers in S simultaneously.
What is the smallest element in S after k days?
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t ( 1≤t≤105 ). The description of the test cases follows.
The first line of each test case consists of two integers n and k ( 1≤n,k≤2⋅105 ) — the length of a and the number of days.
The following line of each test case consists of n integers a1,a2,…,an ( 1≤ai≤109 ) — the elements of array a .
It is guaranteed that:
- The sum of n over all test cases won't exceed 2⋅105 ;
- The sum of k over all test cases won't exceed 2⋅105 ;
- a1<a2<⋯<an for all test cases.
输出格式
For each test case, print an integer that is the smallest element in S after k days.
输入输出样例
输入#1
7 5 1 1 2 4 5 6 5 3 1 3 5 6 7 4 1000 2 3 4 5 9 1434 1 4 7 9 12 15 17 18 20 10 4 1 3 5 7 9 11 13 15 17 19 10 6 1 4 7 10 13 16 19 22 25 28 10 150000 1 3 4 5 10 11 12 13 14 15
输出#1
3 9 1 12874 16 18 1499986
说明/提示
For the first test case, each day the 1 -st, 2 -nd, 4 -th, 5 -th, and 6 -th smallest elements need to be removed from S . So after the first day, S will become \require{cancel} {1,2,3,4,5,6,7,8,9,…}={3,7,8,9,…} . The smallest element is 3 .
For the second case, each day the 1 -st, 3 -rd, 5 -th, 6 -th and 7 -th smallest elements need to be removed from S . S will be changed as follows:
Day S before S after1 {1,2,3,4,5,6,7,8,9,10,…} → {2,4,8,9,10,…} 2 {2,4,8,9,10,11,12,13,14,15,…} → {4,9,13,14,15,…} 3 {4,9,13,14,15,16,17,18,19,20,…} → {9,14,18,19,20,…} The smallest element left after k=3 days is 9 .