#DP1036. Cashback
Cashback
Cashback
题面翻译
给你一个长度为n的数列a和整数c
你需要把它任意分段
每一段假设长度为k,就去掉前 小的数
最小化剩下的数的和
感谢@xzz_233 提供的翻译
题目描述
Since you are the best Wraith King, Nizhniy Magazin «Mir» at the centre of Vinnytsia is offering you a discount.
You are given an array of length and an integer .
The value of some array of length is the sum of its elements except for the smallest. For example, the value of the array with is .
Among all possible partitions of into contiguous subarrays output the smallest possible sum of the values of these subarrays.
输入格式
The first line contains integers and ( ).
The second line contains integers ( ) — elements of .
输出格式
Output a single integer — the smallest possible sum of values of these subarrays of some partition of .
样例 #1
样例输入 #1
3 5
1 2 3
样例输出 #1
6
样例 #2
样例输入 #2
12 10
1 1 10 10 10 10 10 10 9 10 10 10
样例输出 #2
92
样例 #3
样例输入 #3
7 2
2 3 6 4 5 7 1
样例输出 #3
17
样例 #4
样例输入 #4
8 4
1 3 4 5 5 3 4 1
样例输出 #4
23
提示
In the first example any partition yields 6 as the sum.
In the second example one of the optimal partitions is with the values 2 and 90 respectively.
In the third example one of the optimal partitions is with the values 3, 13 and 1 respectively.
In the fourth example one of the optimal partitions is with the values 1, 21 and 1 respectively.