#P7547. [BJWC2017] 太空飞船

[BJWC2017] 太空飞船

Description

This will be a ring-shaped spaceship, consisting of NN cabins in order. The designed length of the ii-th cabin is LiL_i.

To provide energy for the spaceship, KK space energy absorbers need to be installed on the spaceship. According to authoritative theories, these absorbers should be distributed as evenly as possible over the surface of the spaceship. That is, Xiao Cheng needs to divide all NN cabins of the spaceship into KK parts (each part includes a consecutive segment of cabins), and assign one energy absorber to each part. Let the sum of cabin lengths in the ii-th part be sis_i; then the variance should be minimized as much as possible.

However, this problem is too difficult for Xiao Cheng, who is already a senior undergraduate student. Can you help him finish the design? For convenience, output the product of the minimum variance and K2K^2.

Input Format

The input consists of two lines.

The first line contains two integers N,KN, K.

The second line contains NN integers L1,L2,,LNL_1, L_2, \ldots, L_N separated by spaces, representing the length of each cabin in order.

Output Format

Output one line with one integer, representing the product of the minimum variance and K2K^2.

5 3
4 2 6 1 3
24

Hint

Constraints

For 100%100\% of the testdata, N400N \le 400, K20K \le 20, and 1Li1031 \le L_i \le 10^3.

Translated by ChatGPT 5