CF2167E.khba Loves to Sleep!

普及/提高-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

khba has nn friends, each standing on a line at position aia_i, and each of them is in the range [0,x][0, x].

They all want to come to him. One of his friends, Isamatdin, gave him kk teleports. Each friend will walk to the nearest teleport (choosing the shortest distance). Once a friend reaches a teleport, khba and the friend can instantly meet.

But khba is so tired that he'll be sleeping while his friends are walking toward him. Now he wants to choose kk teleport positions so that their positions are distinct and lie within the range [0,x][0, x], in order to maximize the time it takes for the first friend who reaches a teleport to reach it. Assume that friends move at the same speed.

Since khba isn't good at calculations, you should output the kk chosen teleport positions.

khba 有 nn 个朋友,每个人站在一条直线上位置 aia_i 处,且所有人的位置均在区间 [0,x][0, x] 内。

他们都希望来见 khba。他的一个朋友 Isamatdin 给了他 kk 个传送点。每位朋友都会走向离自己最近的传送点(选择最短距离)。一旦某位朋友抵达某个传送点,khba 就能立即与该朋友会面。

但 khba 实在太累了,朋友们朝他走来时他将处于睡眠状态。现在他希望选择 kk 个互不相同的传送点位置,且这些位置均需落在区间 [0,x][0, x] 内,使得第一个抵达传送点的朋友所花费的时间尽可能长。假设所有朋友的行走速度相同。

由于 khba 不擅长计算,你需要输出这 kk 个选定的传送点位置。

输入格式

Each test contains multiple test cases. The first line contains a single integer tt (1≤t≤1041 \leq t \leq 10^4) — the number of test cases. The description of the test cases follows.

The first line of each test case contains three integers nn, kk, and xx (1≤n,k≤2⋅1051 \leq n, k \leq 2 \cdot 10^5, k−1≤x≤109k - 1 \leq x \leq 10^9) — the number of friends, the number of teleports, and the range of possible positions for the teleports.

The second line of each test case contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (0≤ai≤x0 \leq a_i \leq x) — the positions of khba's friends.

It is guaranteed that the sum of nn over all test cases does not exceed 2⋅1052 \cdot 10^5.

It is guaranteed that the sum of kk over all test cases does not exceed 2⋅1052 \cdot 10^5.

每个测试包含多个测试用例。第一行包含一个整数 tt(1≤t≤1041 \leq t \leq 10^4),表示测试用例的数量。随后是各测试用例的描述。

每个测试用例的第一行包含三个整数 nn、kk 和 xx(1≤n,k≤2⋅1051 \leq n, k \leq 2 \cdot 10^5,k−1≤x≤109k - 1 \leq x \leq 10^9),分别表示朋友的数量、传送门的数量以及传送门可能位置的范围。

每个测试用例的第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n(0≤ai≤x0 \leq a_i \leq x),表示 khba 的朋友们的位置。

保证所有测试用例中 nn 的总和不超过 2⋅1052 \cdot 10^5。

保证所有测试用例中 kk 的总和不超过 2⋅1052 \cdot 10^5。

输出格式

For each test case, output a single line containing kk integers — the kk chosen teleport positions. The positions must be distinct and lie within the range [0,x][0, x]. The positions may be output in any order.

If there are multiple optimal choices, output any of them.

对于每个测试用例,输出一行包含 kk 个整数——即所选的 kk 个传送位置。这些位置必须互不相同,且均在区间 [0,x][0, x] 内。位置的输出顺序可以任意。

若存在多种最优选择,输出其中任意一种即可。

输入输出样例

  • 输入#1

    10
    4 1 4
    1 0 2 4
    5 5 4
    0 1 2 3 4
    2 1 4
    4 0
    3 4 6
    2 4 3
    3 2 12
    6 12 0
    4 3 12
    8 12 0 4
    1 1 1000000000
    0
    1 1 1000000000
    1000000000
    3 4 9
    8 7 9
    3 4 9
    2 0 1

    输出#1

    3 
    0 1 2 3 4 
    2 
    0 1 5 6 
    3 9 
    2 6 10 
    1000000000 
    0 
    0 1 2 3 
    6 7 8 9

说明/提示

Sample 1. Friends at positions [1,0,2,4][1,0,2,4]. Chosen teleport position: [3][3].

Nearest teleport for each friend is in 33, minimal times for friends are [2,3,1,1][2, 3, 1, 1], respectively.

Sample 2. Friends at positions [0,1,2,3,4][0,1,2,3,4]. Chosen teleport positions: [0,1,2,3,4][0,1,2,3,4].

Minimal times for friends are [0,0,0,0,0][0, 0, 0, 0, 0], respectively.

Sample 3. Friends at positions [4,0][4,0]. Chosen teleport position: [2][2].

Minimal times for friends are [2,2][2, 2], respectively.

Sample 4. Friends at positions [2,4,3][2,4,3]. Chosen teleport positions: [0,1,5,6][0,1,5,6].

Minimal times for friends are [1,1,2][1, 1, 2], respectively.

Sample 5. Friends at positions [6,12,0][6,12,0]. Chosen teleport positions: [3,9][3,9].

Minimal times for friends are [3,3,3][3, 3, 3], respectively.

样例 1:朋友位于位置 [1,0,2,4][1,0,2,4],选择的传送点位置为 [3][3]。
每位朋友最近的传送点均为 33,各位朋友所需的最少时间为 [2,3,1,1][2, 3, 1, 1]。

样例 2:朋友位于位置 [0,1,2,3,4][0,1,2,3,4],选择的传送点位置为 [0,1,2,3,4][0,1,2,3,4]。
各位朋友所需的最少时间为 [0,0,0,0,0][0, 0, 0, 0, 0]。

样例 3:朋友位于位置 [4,0][4,0],选择的传送点位置为 [2][2]。
各位朋友所需的最少时间为 [2,2][2, 2]。

样例 4:朋友位于位置 [2,4,3][2,4,3],选择的传送点位置为 [0,1,5,6][0,1,5,6]。
各位朋友所需的最少时间为 [1,1,2][1, 1, 2]。

样例 5:朋友位于位置 [6,12,0][6,12,0],选择的传送点位置为 [3,9][3,9]。
各位朋友所需的最少时间为 [3,3,3][3, 3, 3]。

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

首页