304955: CF940E. Cashback

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

Description

Cashback

题意翻译

给你一个长度为n的数列a和整数c 你需要把它任意分段 每一段假设长度为k,就去掉前$\lfloor\frac{k}{c}\rfloor$ 小的数 最小化剩下的数的和 感谢@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 $ a $ of length $ n $ and an integer $ c $ . The value of some array $ b $ of length $ k $ is the sum of its elements except for the ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF940E/7767e68a87566f0732f029bd691b100b0a741ae2.png) smallest. For example, the value of the array $ [3,1,6,5,2] $ with $ c=2 $ is $ 3+6+5=14 $ . Among all possible partitions of $ a $ into contiguous subarrays output the smallest possible sum of the values of these subarrays.

输入输出格式

输入格式


The first line contains integers $ n $ and $ c $ ( $ 1<=n,c<=100000 $ ). The second line contains $ n $ integers $ a_{i} $ ( $ 1<=a_{i}<=10^{9} $ ) — elements of $ a $ .

输出格式


Output a single integer — the smallest possible sum of values of these subarrays of some partition of $ a $ .

输入输出样例

输入样例 #1

3 5
1 2 3

输出样例 #1

6

输入样例 #2

12 10
1 1 10 10 10 10 10 10 9 10 10 10

输出样例 #2

92

输入样例 #3

7 2
2 3 6 4 5 7 1

输出样例 #3

17

输入样例 #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 $ [1,1],[10,10,10,10,10,10,9,10,10,10] $ with the values 2 and 90 respectively. In the third example one of the optimal partitions is $ [2,3],[6,4,5,7],[1] $ with the values 3, 13 and 1 respectively. In the fourth example one of the optimal partitions is $ [1],[3,4,5,5,3,4],[1] $ with the values 1, 21 and 1 respectively.

Input

题意翻译

给你一个长度为n的数列a和整数c 你需要把它任意分段 每一段假设长度为k,就去掉前$\lfloor\frac{k}{c}\rfloor$ 小的数 最小化剩下的数的和 感谢@xzz_233 提供的翻译

加入题单

上一题 下一题 算法标签: