rewards lists the rewards lying on a table. Your pile starts at 0 points.
You may take rewards one at a time in any order, each at most once. A reward of value v can be taken only if v is **strictly greater** than the current total of your pile; taking it adds v to the total. You do not have to take every reward.
Return the largest total you can collect.rewards=[2, 5, 3, 3] → 8
Take 2 (2 > 0), then 3 (3 > 2) for a total of 5; now 5 is no longer larger than 5. A better order: 3, then 5, for a total of 8, which is the best possible.
rewards=[4, 4, 4] → 4
The first 4 is taken; every other 4 is no longer larger than the 4 already collected.
rewards=[1, 7, 2, 9, 4] → 17
rewards=[2, 5, 3, 3]
8
Run checks the first 3 tests in your browser. Submit checks all 105 tests on the server, hidden ones included.