← 返回 amazon 的题目列表Maximize Total Memory Points by Permuting Chapter Order
类型:online_judge
amazon
Amazon Academy has launched a new course on Quantum Physics. The course has n chapters, each chapter has memory[i] memory points, which a student gains or loses while reading that chapter. The course has a requirement: In order to study the i-th chapter, the student must revisit all the previous chapters.
Students need to read all chapters in any order and want to maximize their total memory points. Find the maximum total chapters a student can score ensuring that all chapters are read.
Example:
memory = [3, 5, 4] The maximum achievable memory points is 26 considering all permutations of reading the chapters.
Example
Input
3
3 5 4