AtCoder Regular Contest 167
翻译中…
Problem Statement
翻译中…
We have $N$ slices of toast and $M$ plates. $M$ is an integer between $\frac{N}{2}$ and $N$, inclusive. The $i$-th slice of toast has a deliciousness of $A_{i}$.
翻译中…
Let us put the $N$ slices of toast on the $M$ plates to satisfy the following two conditions.
翻译中…
- Each plate can have at most two slices of toast on it.
- Every slice of toast is on some plate.
翻译中…
Let $B_{j}$ be the sum of the deliciousness of the toast on the $j$-th plate ($0$ if the plate has no toast on it). Then, let the unbalancedness be $\sum_{j=1}^{M} B_{j}^{2}$.
翻译中…
Find the minimum possible value of the unbalancedness.
翻译中…
Constraints
翻译中…
$1\leq N\leq 2\times 10^{5}$$\frac{N}{2}\leq M\leq N$$1\leq A_{i}\leq 2\times 10^{5}$- All input values are integers.
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
N M
A_{1} A_{2} \cdots A_{N}
翻译中…
Output
翻译中…
Print the answer.
翻译中…
样例
Input #1
5 3
1 1 1 6 7
Output #1
102
If you put the first and second slices on the first plate, the third and fourth slices on the second plate, and the fifth slice on the third plate, we have $(1+1)^{2}+(1+6)^{2}+7^2=102$, so the unbalancedness is $102$.
There is no way to put them to make the unbalancedness less than $102$, so print $102$.
Note that you cannot put the first, second, and third slices on the same plate.
Input #2
2 1
167 924
Output #2
1190281
Input #3
12 9
22847 98332 854 68844 81080 46058 40949 62493 76561 52907 88628 99740
Output #3
61968950639
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。