CF1852A.Ntarsis' Set

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Ntarsis has been given a set SS, initially containing integers 1,2,3,…,1010001, 2, 3, \ldots, 10^{1000} in sorted order. Every day, he will remove the a1a_1-th, a2a_2-th, …\ldots, ana_n-th smallest numbers in SS simultaneously.

What is the smallest element in SS after kk days?

Ntarsis 得到了一个集合 SS,初始时按升序包含整数 1,2,3,…,1010001, 2, 3, \ldots, 10^{1000}。每天,他将同时删除 SS 中第 a1a_1 小、第 a2a_2 小、……、第 ana_n 小的数。

经过 kk 天后,SS 中最小的元素是多少?

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1051 \le t \le 10^5). The description of the test cases follows.

The first line of each test case consists of two integers nn and kk (1≤n,k≤2⋅1051 \leq n,k \leq 2 \cdot 10^5) — the length of aa and the number of days.

The following line of each test case consists of nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤1091 \leq a_i \leq 10^9) — the elements of array aa.

It is guaranteed that:

  • The sum of nn over all test cases won't exceed 2⋅1052 \cdot 10^5;
  • The sum of kk over all test cases won't exceed 2⋅1052 \cdot 10^5;
  • a1<a2<⋯<ana_1 \lt a_2 \lt \cdots \lt a_n for all test cases.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤1051 \le t \le 10^5)。随后是各测试用例的描述。

每个测试用例的第一行包含两个整数 nn 和 kk(1≤n,k≤2⋅1051 \leq n,k \leq 2 \cdot 10^5)——分别表示数组 aa 的长度和天数。

每个测试用例的下一行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤1091 \leq a_i \leq 10^9)——即数组 aa 的元素。

保证满足以下条件:

  • 所有测试用例中 nn 的总和不超过 2⋅1052 \cdot 10^5;
  • 所有测试用例中 kk 的总和不超过 2⋅1052 \cdot 10^5;
  • 对所有测试用例,均有 a1<a2<⋯<ana_1 \lt a_2 \lt \cdots \lt a_n。

输出格式

For each test case, print an integer that is the smallest element in SS after kk days.

对于每个测试用例,输出一个整数,表示经过 kk 天后集合 SS 中的最小元素。

输入输出样例

  • 输入#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 11-st, 22-nd, 44-th, 55-th, and 66-th smallest elements need to be removed from SS. So after the first day, SS will become \require{cancel} 1,2,3,4,5,6,7,8,9,…=3,7,8,9,…{\cancel 1, \cancel 2, 3, \cancel 4, \cancel 5, \cancel 6, 7, 8, 9, \ldots} = {3, 7, 8, 9, \ldots}. The smallest element is 33.

For the second case, each day the 11-st, 33-rd, 55-th, 66-th and 77-th smallest elements need to be removed from SS. SS will be changed as follows:

Day

SS before

SS after

1

1,2,3,4,5,6,7,8,9,10,…{\cancel 1, 2, \cancel 3, 4, \cancel 5, \cancel 6, \cancel 7, 8, 9, 10, \ldots }

→\to

2,4,8,9,10,…{2, 4, 8, 9, 10, \ldots}

2

2,4,8,9,10,11,12,13,14,15,…{\cancel 2, 4, \cancel 8, 9, \cancel{10}, \cancel{11}, \cancel{12}, 13, 14, 15, \ldots}

→\to

4,9,13,14,15,…{4, 9, 13, 14, 15, \ldots}

3

4,9,13,14,15,16,17,18,19,20,…{\cancel 4, 9, \cancel{13}, 14, \cancel{15}, \cancel{16}, \cancel{17}, 18, 19, 20, \ldots}

→\to

9,14,18,19,20,…{9, 14, 18, 19, 20, \ldots}

The smallest element left after k=3k = 3 days is 99.

对于第一个测试用例,每天需要从集合 SS 中移除第 11 小、第 22 小、第 44 小、第 55 小和第 66 小的元素。因此,第一天之后,SS 将变为 \require{cancel} 1,2,3,4,5,6,7,8,9,…=3,7,8,9,…{\cancel 1, \cancel 2, 3, \cancel 4, \cancel 5, \cancel 6, 7, 8, 9, \ldots} = {3, 7, 8, 9, \ldots}。此时最小的元素为 33。

对于第二个测试用例,每天需要从集合 SS 中移除第 11 小、第 33 小、第 55 小、第 66 小和第 77 小的元素。SS 的变化过程如下:

天数 变化前的 SS 变化后的 SS
1 1,2,3,4,5,6,7,8,9,10,…{\cancel 1, 2, \cancel 3, 4, \cancel 5, \cancel 6, \cancel 7, 8, 9, 10, \ldots } →\to
2 2,4,8,9,10,11,12,13,14,15,…{\cancel 2, 4, \cancel 8, 9, \cancel{10}, \cancel{11}, \cancel{12}, 13, 14, 15, \ldots} →\to
3 4,9,13,14,15,16,17,18,19,20,…{\cancel 4, 9, \cancel{13}, 14, \cancel{15}, \cancel{16}, \cancel{17}, 18, 19, 20, \ldots} →\to

经过 k=3k = 3 天后,剩余元素中最小的值为 99。

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

首页