CF1175G.Yet Another Partiton Problem
NOI/NOI+/CTSC
通过率:0%
时间限制:5.00s
内存限制:512MB
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.
给你一个数组 a1,a2,…,an。你需要将其划分为 k 个子段(即每个元素恰好属于其中一个子段)。
子段 al,al+1,…,ar 的权重定义为 (r−l+1)⋅l≤i≤rmax(ai)。一个划分的权重定义为该划分中所有子段的权重之和。
请找出权重最小的划分。
输入格式
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.
第一行包含两个整数 n 和 k(1≤n≤2⋅104,1≤k≤min(100,n))—— 分别表示数组 a 的长度以及划分中子区间的个数。
第二行包含 n 个整数 a1,a2,…,an(1≤ai≤2⋅104)—— 数组 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.
第一个样例的最优划分如下:6 1 7 4。
第二个样例的最优划分如下:6 1 7 4。
第三个样例的一个最优划分如下:5 1 5 1 5。
输入解题思路,AI测评打分。不知道怎么写?