CF1428E.Carrots for Rabbits
提高+/省选-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are some rabbits in Singapore Zoo. To feed them, Zookeeper bought n carrots with lengths a1,a2,a3,…,an. However, rabbits are very fertile and multiply very quickly. Zookeeper now has k rabbits and does not have enough carrots to feed all of them. To solve this problem, Zookeeper decided to cut the carrots into k pieces. For some reason, all resulting carrot lengths must be positive integers.
Big carrots are very difficult for rabbits to handle and eat, so the time needed to eat a carrot of size x is x2.
Help Zookeeper split his carrots while minimizing the sum of time taken for rabbits to eat the carrots.
新加坡动物园里有一些兔子。为了喂养它们,饲养员购买了 n 根胡萝卜,长度分别为 a1,a2,a3,…,an。然而,兔子繁殖能力极强,数量增长很快。如今饲养员有 k 只兔子,但胡萝卜数量不足,无法喂饱所有兔子。为解决这一问题,饲养员决定将胡萝卜切成总共 k 段。出于某种原因,所有切分后胡萝卜的长度必须为正整数。
大块胡萝卜对兔子而言很难处理和进食,因此兔子吃掉一根长度为 x 的胡萝卜所需时间为 x2。
请帮助饲养员切分胡萝卜,使得所有兔子吃完胡萝卜所需的总时间最小。
输入格式
The first line contains two integers n and k (1≤n≤k≤105): the initial number of carrots and the number of rabbits.
The next line contains n integers a1,a2,…,an (1≤ai≤106): lengths of carrots.
It is guaranteed that the sum of ai is at least k.
第一行包含两个整数 n 和 k (1≤n≤k≤105):初始胡萝卜的数量和兔子的数量。
第二行包含 n 个整数 a1,a2,…,an (1≤ai≤106):胡萝卜的长度。
保证所有 ai 的总和至少为 k。
输出格式
Output one integer: the minimum sum of time taken for rabbits to eat carrots.
输出一个整数:兔子吃胡萝卜所需时间的最小总和。
输入输出样例
输入#1
3 6 5 3 1
输出#1
15
输入#2
1 4 19
输出#2
91
说明/提示
For the first test, the optimal sizes of carrots are 1,1,1,2,2,2. The time taken is 12+12+12+22+22+22=15
For the second test, the optimal sizes of carrots are 4,5,5,5. The time taken is 42+52+52+52=91.
对于第一个测试用例,胡萝卜的最优尺寸为 1,1,1,2,2,2。所用时间为 12+12+12+22+22+22=15。
对于第二个测试用例,胡萝卜的最优尺寸为 4,5,5,5。所用时间为 42+52+52+52=91。
输入解题思路,AI测评打分。不知道怎么写?