A11590 | Cashback
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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  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.
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  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$ .
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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted