跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F1071. Array Covering

  • ID: 1077
  • 传统题
  • 2000ms
  • 256MiB
  • 尝试: 0
  • AC · 已通过: 0
  • 教学难度:挑战
  • 上传者:
  • 数据结构
  • 挑战
  • 难度
  • 共享题库
  • Codeforces
  • 英文题面
  • 题目来源
  • 题面语言

Array Covering

题目描述

F. Array Covering
time limit per test
3 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Input

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 ai (-50000≤ai≤50000)− the elements of the array.

Output

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

Example
Input
5 4
6 -4 -10 -4 7
Output
11


题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 533 题。保留原作者与原赛事署名。