303730: CF720F. Array Covering

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

Description

Array Covering

题意翻译

给定一个长度为 $n$ 的序列 $a$。 你需要选出 $k$ 个不同的子序列 $[l_i, r_i]$,使得它们的并为 $[1, n]$,求子序列和的最大值。

题目描述

Misha has an array of integers of length $ n $ . He wants to choose $ k $ different continuous subarrays, so that each element of the array belongs to at least one of the chosen subarrays. Misha wants to choose the subarrays in such a way that if he calculated the sum of elements for each subarray, and then add up all these sums, the resulting value was maximum possible.

输入输出格式

输入格式


The first line of input contains two integers: $ n $ , $ k $ ( $ 1<=n<=100000 $ , $ 1<=k<=n·(n+1)/2 $ ) — the number of elements in the array and the number of different subarrays that must be chosen. The second line contains $ n $ integers $ a_{i} $ ( $ -50000<=a_{i}<=50000 $ ) — the elements of the array.

输出格式


Output one integer — the maximum possible value Misha can get by choosing $ k $ different subarrays.

输入输出样例

输入样例 #1

5 4
6 -4 -10 -4 7

输出样例 #1

11

Input

题意翻译

给定一个长度为 $n$ 的序列 $a$。 你需要选出 $k$ 个不同的子序列 $[l_i, r_i]$,使得它们的并为 $[1, n]$,求子序列和的最大值。

加入题单

算法标签: