409425: GYM103536 A Guards

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Guardstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

There are $$$N$$$ prisoners in jail cells numbered from $$$0$$$ to $$$N-1$$$ and $$$G$$$ guards. The guards ensure the prisoners do not escape and can only take charge of adjacent segments of jail cells. Each jail cell is assigned to exactly one guard.

Each prisoner $$$i$$$ has a certain intelligence $$$S_i$$$, and if the guard is watching him has $$$k$$$ people to watch over, his escaping possibility will be $$$kS_i$$$. You should assign the guards so that the total escaping possibility over all the prisoners is minimized.

Input

The first line of input contains $$$2$$$ integers $$$N$$$ and $$$G$$$ ($$$1 \leq 8000 \leq N,1 \leq 3000 \leq G$$$).

The next $$$N$$$ lines of input will contain one integer each, $$$S_i$$$ ($$$1 \leq S_i \leq 10^9$$$).

Output

The output should contain one line with one integer, the minimum total escaping possibility.

ExampleInput
6 3
11
11
11
24
26
100
Output
299

加入题单

上一题 下一题 算法标签: