#435
Unrated
Snakes
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

According to legend, St. Patrick banished all of the snakes in Mooland over a thousand years ago. However, snakes have since made their way back to Mooland! St. Patrick’s day was on March 17, so Bessie is going to commemorate St. Patrick by banishing all of the snakes from Mooland once and for all.

Bessie is equipped with a net to capture snakes distributed in NN groups on a line (1N400)(1 \leq N \leq 400). Bessie must capture every snake in every group in the order that the groups appear on the line. Each time Bessie captures a group, she can put the snakes in a cage and start with an empty net for the next group.

A net with size ss means that Bessie can capture any group that contains gg snakes, where gsg \leq s. However, every time Bessie captures a group of snakes of size gg with a net of size ss, she wastes sgs - g space. Bessie’s net can start at any size and she can change the size of her net KK times (1K<N)(1 \leq K < N).

Please tell Bessie the minimum amount of total wasted space she can accumulate after capturing all the groups.

입력

The first line contains NN and KK. The second line contains NN integers, a1,,aNa_1,\dots,a_N, where aia_i (0ai1060 \leq a_i \leq 10^6) is the number of snakes in the iith group.

출력

Output one integer giving the minimum amount of wasted space after Bessie captures all the snakes.

예제 입력 1

6 2
7 9 8 2 3 2

예제 출력 1

3
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.