#P10478. 生日礼物
生日礼物
Problem Description
On ftiasch's 18th birthday, lqp18_31 showed her a magical sequence , , ..., . She is allowed to choose at most consecutive segments as her birthday gift.
Naturally, ftiasch wants to know the maximum possible sum of the selected elements. Can you help her?
Input Format
Line 1: Two integers () and (), representing the length of the sequence and the number of segments that can be chosen.
Line 2: integers , , ..., (), representing the sequence.
Output Format
One integer, representing the maximum sum.
5 2
2 1 -2 3 -2
6
Hint
Translated by ChatGPT 5