CF1175G.Yet Another Partiton Problem
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given array a1,a2,…,an . You need to split it into k subsegments (so every element is included in exactly one subsegment).
The weight of a subsegment al,al+1,…,ar is equal to (r−l+1)⋅l≤i≤rmax(ai) . The weight of a partition is a total weight of all its segments.
Find the partition of minimal weight.
输入格式
The first line contains two integers n and k ( 1≤n≤2⋅104 , 1≤k≤min(100,n) ) — the length of the array a and the number of subsegments in the partition.
The second line contains n integers a1,a2,…,an ( 1≤ai≤2⋅104 ) — the array a .
输出格式
Print single integer — the minimal weight among all possible partitions.
输入输出样例
输入#1
4 2 6 1 7 4
输出#1
25
输入#2
4 3 6 1 7 4
输出#2
21
输入#3
5 4 5 1 5 1 5
输出#3
21
说明/提示
The optimal partition in the first example is next: 6 1 7 4 .
The optimal partition in the second example is next: 6 1 7 4 .
One of the optimal partitions in the third example is next: 5 1 5 1 5 .