← 返回 amazon 的题目列表Maximum Sum Strictly Increasing Subsequence from Contiguous Piles
类型:online_judge
amazon
Problem 2: Maximum Sum of Strictly Increasing Subsequence
Given n piles of products, each with a random quantity sequence, e.g., [5,6,7,2,4]. The requirements are:
Select a contiguous subsequence of m piles from the n piles; for example, you can choose from the second to fourth piles, i.e., [6,7,2].
Then, for the selected subsequence, retrieve a certain quantity from each position (not exceeding the total at that position) to form a strictly increasing sequence.
Return the maximum possible sum of products forming a strictly increasing sequence.
Example
Input
5
3
5 6 7 2 4