values. You want to claim a set of items whose total value is **strictly greater** than the total value of everything left to the crew.
Claim as few items as possible, and among all choices with that smallest number of items, pick the one with the largest total value. It can be shown that the resulting values are uniquely determined.
Return the values of the claimed items in non-increasing order.values=[3, 8, 2, 7, 5] → [8, 7]
The total is 25. One item is not enough: 8 < 17. The two most valuable give 8 + 7 = 15 > 10, so that is the answer.
values=[6, 6, 6, 6] → [6, 6, 6]
Two sixes give 12, exactly as much as is left, but the share must be strictly larger, so three are needed.
values=[50] → [50]
values=[3, 8, 2, 7, 5]
[8, 7]
Run checks the first 3 tests in your browser. Submit checks all 57 tests on the server, hidden ones included.