#Q178. 「一本通 5.5 例 2」最大连续和
「一本通 5.5 例 2」最大连续和
Description
You are given an integer sequence of length . Your task is to find a non-empty contiguous subsequence with a length not exceeding such that the sum of this subsequence is maximized.
Input Format
The first line contains two integers and ;
The second line contains integers separated by spaces, where the absolute value of each number is less than .
Output Format
Output a single integer representing the maximum sum of a non-empty contiguous subsequence with length not exceeding .
Sample 1
6 4
1 -3 5 1 -2 3
7
Constraints & Hints
For of the test cases, ;
For of the test cases, .