CF1515C.Phoenix and Towers

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Phoenix has nn blocks of height h1,h2,,hnh_1, h_2, \dots, h_n , and all hih_i don't exceed some value xx . He plans to stack all nn blocks into mm separate towers. The height of a tower is simply the sum of the heights of its blocks. For the towers to look beautiful, no two towers may have a height difference of strictly more than xx .

Please help Phoenix build mm towers that look beautiful. Each tower must have at least one block and all blocks must be used.

输入格式

The input consists of multiple test cases. The first line contains an integer tt ( 1t10001 \le t \le 1000 ) — the number of test cases.

The first line of each test case contains three integers nn , mm , and xx ( 1mn1051 \le m \le n \le 10^5 ; 1x1041 \le x \le 10^4 ) — the number of blocks, the number of towers to build, and the maximum acceptable height difference of any two towers, respectively.

The second line of each test case contains nn space-separated integers ( 1hix1 \le h_i \le x ) — the heights of the blocks.

It is guaranteed that the sum of nn over all the test cases will not exceed 10510^5 .

输出格式

For each test case, if Phoenix cannot build mm towers that look beautiful, print NO. Otherwise, print YES, followed by nn integers y1,y2,,yny_1, y_2, \dots, y_n , where yiy_i ( 1yim1 \le y_i \le m ) is the index of the tower that the ii -th block is placed in.

If there are multiple solutions, print any of them.

输入输出样例

  • 输入#1

    2
    5 2 3
    1 2 3 1 2
    4 3 3
    1 1 2 3

    输出#1

    YES
    1 1 1 2 2
    YES
    1 2 2 3

说明/提示

In the first test case, the first tower has height 1+2+3=61+2+3=6 and the second tower has height 1+2=31+2=3 . Their difference is 63=36-3=3 which doesn't exceed x=3x=3 , so the towers are beautiful.

In the second test case, the first tower has height 11 , the second tower has height 1+2=31+2=3 , and the third tower has height 33 . The maximum height difference of any two towers is 31=23-1=2 which doesn't exceed x=3x=3 , so the towers are beautiful.

首页