K-th Largest Subarray Sum
Given an array with n elements, what is the k-th largest sub array sum. (A subarray sum is the sum of all elements within a continuous section of the array).
Input
The first line contain integers n and k. The second line contains n integers a1,…,an, the elements of the array.
Output
Output the k-th largest subarray sum.
Constraints
- 1≤n≤104
- 1≤k≤2n(n+1)
- 1≤ai≤109
Example 1
10 1
7 7 4 6 3 8 9 8 5 1
58
Example 2
3 4
8 10 4
10
Example 3
5 6
3 6 9 8 4
18
Comments0
No comments yet
Be the first to comment.
New comment
Log in to join the discussion.