CF1515C Phoenix and Towers
题目描述
凤凰菲克斯有 $ n $ 个方块,分别高 $ h_1,h2,\dots,h_n $,所有 $ h_i $ 都不超过 $ x $ 。他计划将 $ n $ 个方块堆叠成 $ m $ 座塔。为了让塔看起来更漂亮,没有两座塔的高度差可以超过 $ x $ 。
请帮助菲克斯建造 $ m $ 座漂亮的塔,每个塔必须至少由一个方块构成,并且必须使用所有方块。
输入格式
有多组数据。
第一行输入一个正整数 $ T $($ 1 \le T \le 1000 $ ),表示数据的组数。
对于每组数据:
第一行输入三个正整数:$ n $ , $ m $ , $ x $ ( $ 1 \le m \le n \le 10^5 $ ; $ 1 \le x \le 10^4 $ ) 意义如题面中所述。分别是方块数、要建造的塔数和任意两个塔的最大可接受高度差。
第二行包含 $ n $ 个用空格分隔的整数($1\le h_i\le x$)表示块的高度。
保证所有测试用例的 $ n $ 总和不会超过 $ 10^5 $ 。
输出格式
对于每组数据:
若菲克斯不能建造 $ m $ 座漂亮的塔,输出一个 "NO"。
否则,在第一行输出一个"YES"。后跟 $ n $ 个整数 $ y_1, y_2, \dots, y_n $ , 其中 $ y_i $ ($1\le y_i\le m$)表示 $ i $ 座塔的高度。
如果有多种解决方案,请输出其中任意一种。
说明/提示
In the first test case, the first tower has height $ 1+2+3=6 $ and the second tower has height $ 1+2=3 $ . Their difference is $ 6-3=3 $ which doesn't exceed $ x=3 $ , so the towers are beautiful.
In the second test case, the first tower has height $ 1 $ , the second tower has height $ 1+2=3 $ , and the third tower has height $ 3 $ . The maximum height difference of any two towers is $ 3-1=2 $ which doesn't exceed $ x=3 $ , so the towers are beautiful.