#P5745. 【深基附B例】区间最大和
【深基附B例】区间最大和
Description
Given a sequence of positive integers and an integer , find a subinterval , that is, a consecutive part of the sequence , such that the sum of this subinterval is as large as possible while not exceeding . If multiple intervals meet the requirement, output the one with the smallest .
Input Format
The input has two lines.
The first line contains two integers .
The second line contains integers .
Output Format
Output one line with three integers, representing the left endpoint, the right endpoint, and the cumulative sum of the interval that meets the requirement.
5 10
2 3 4 5 6
1 3 9
Hint
Subtask 1 (10 points): .
Subtask 2 (20 points): .
Subtask 3 (30 points): .
Subtask 4 (40 points): .
For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号