← 返回 amazon 的题目列表Maximal Total Value of Groups
类型:online_judge
Divide an array into groups where each group must have exactly three elements. Groups cannot be formed with fewer than three elements. The value of a group is determined by its median, and the total value of the array is the sum of all group values. Find the maximal total value. For example, given the array [9, 7, 5, 8, 6, 4, 3], the maximal total value is 22.
Example
Input
7
9 7 5 8 6 4 3