← 返回 amazon 的题目列表Maximize Memory Points for Chapters
类型:online_judge
A course consists of n chapters, with each chapter having memory[i] memory points gained or lost while reading. The course requirement states that the ith chapter can only be studied if all previous chapters are revisited. A student gains memory[0] + memory[1] + ... + memory[i] memory points for reading the ith chapter. The total memory points is the sum of memory points gained from each chapter. Students can read chapters in any order, aiming to maximize total memory points. Find the maximum total memory points ensuring all chapters are read.
Example
Input
5
[10, -5, 20, -10, 30]