Problem H: 1201 最大子序和
Memory Limit:128 MB
Time Limit:1.000 S
Judge Style:Text Compare
Creator:
Submit:15
Solved:5
Description
输入一个长度为n的整数序列,从中找出一段不超过m的连续子序列,使得整个序列的和最大。
例如 1,-3,5,1,-2,3
当m=4时,S=5+1-2+3=7
当m=2或m=3时,S=5+1=6
Input
第一行两个数n,m(n,m<=300000)
第二行有n个数,要求在n个数找到最大子序和
第二行有n个数,要求在n个数找到最大子序和
Output
一个数,数出他们的最大子序和
Sample Input Copy
6 4
1 -3 5 1 -2 3
Sample Output Copy
7