CF1515C Phoenix and Towers

题目描述

凤凰菲克斯有 $ n $ 个方块,分别高 $ h_1,h2,\dots,h_n $,所有 $ h_i $ 都不超过 $ x $ 。他计划将 $ n $ 个方块堆叠成 $ m $ 座塔。为了让塔看起来更漂亮,没有两座塔的高度差可以超过 $ x $ 。 请帮助菲克斯建造 $ m $ 座漂亮的塔,每个塔必须至少由一个方块构成,并且必须使用所有方块。

输入格式

输出格式

说明/提示

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.