标签:eric 技术 getchar 数组 examples 并且 lag pow rap
You are given an array ??1,??2,…,???? and an integer ??
.
You are asked to divide this array into ??
non-empty consecutive subarrays. Every element in the array should be included in exactly one subarray. Let ?? be the index of subarray the ??-th element belongs to. Subarrays are numbered from left to right and from 1 to ??
.
Let the cost of division be equal to ∑??=1??(????⋅??
. For example, if ??=[1,−2,−3,4,−5,6,−7] and we divide it into 3 subbarays in the following way: [1,−2,−3],[4,−5],[6,−7], then the cost of division is equal to 1⋅1−2⋅1−3⋅1+4⋅2−5⋅2+6⋅3−7⋅3=−9
.
Calculate the maximum cost you can obtain by dividing the array ??
into ??
non-empty consecutive subarrays.
The first line contains two integers ??
and ?? (1≤??≤??≤3⋅105
).
The second line contains ??
integers ??1,??2,…,???? (|????|≤106
).
Print the maximum cost you can obtain by dividing the array ??
into ??
标签:eric 技术 getchar 数组 examples 并且 lag pow rap
原文地址:https://www.cnblogs.com/cherish-lin/p/10989001.html