欢迎光临散文网 会员登陆 & 注册

CF 1849B - Monsters

2023-08-16 11:28 作者:您是打尖儿还是住店呢  | 我要投稿

outputstandard output

Monocarp is playing yet another computer game. And yet again, his character is killing some monsters. There are n monsters, numbered from 1 to n, and the i-th of them has ai health points initially.

Monocarp's character has an ability that deals k damage to the monster with the highest current health. If there are several of them, the one with the smaller index is chosen. If a monster's health becomes less than or equal to 0 after Monocarp uses his ability, then it dies.


Monocarp uses his ability until all monsters die. Your task is to determine the order in which monsters will die.

Input

The first line contains a single integer t (1≤t≤104) — the number of test cases.


The first line of each test case contains two integers n and k (1≤n≤3⋅105; 1≤k≤109) — the number of monsters and the damage which Monocarp's ability deals.


The second line contains n integers a1,a2,…,an (1≤ai≤109) — the initial health points of monsters.

The sum of n over all test cases doesn't exceed 3⋅105.

Output

For each test case, print n integers — the indices of monsters in the order they die.

---------------------------------------

输出标准输出

Monocarp 正在玩另一个电脑游戏。 再一次,他的角色正在杀死一些怪物。 有 n 个怪物,编号从 1 到 n,其中第 i 个怪物最初有 ai 生命值。

Monocarp 的角色有一种能力,可以对当前生命值最高的怪物造成 k 点伤害。 如果有多个,则选择索引较小的一个。 如果在 Monocarp 使用他的能力后怪物的生命值变得小于或等于 0,那么它就会死亡。


Monocarp 使用他的能力直到所有怪物死亡。 你的任务是确定怪物的死亡顺序。

输入

第一行包含一个整数 t (1≤t≤104) — 测试用例的数量。


每个测试用例的第一行包含两个整数n和k(1≤n≤3⋅105;1≤k≤109)——怪物的数量和Monocarp能力造成的伤害。


第二行包含n个整数a1,a2,…,an (1≤ai≤109)——怪物的初始生命值。

所有测试用例的 n 总和不超过 3⋅105。

输出

对于每个测试用例,打印 n 个整数——按照怪物死亡顺序排列的索引。

----------------------------------

每个怪物的生命值要对k求余,只是为0 的要改成k,然后保存一个二维数组,0处放生命值,剩下的放索引值,然后输出即可,

下面是代码:


CF 1849B - Monsters的评论 (共 条)

分享到微博请遵守国家法律