table of positive integers in which every row has the same length. A game is played in rounds until the table is empty:
- every row loses its largest number (if there are several, any one of them);
- the score grows by the largest of the numbers removed in that round.
Each round makes every row one element shorter. Return the final score.table=[[2, 7, 5], [6, 1, 6]] → 15
Round 1 removes 7 and 6 and scores 7. Round 2 removes 5 and 6 and scores 6. Round 3 removes 2 and 1 and scores 2. Total: 7 + 6 + 2 = 15.
table=[[4], [9], [1]] → 9
There is only one round, and the largest removed number in it is 9.
table=[[3, 3]] → 6
table=[[2, 7, 5], [6, 1, 6]]
15
Run checks the first 3 tests in your browser. Submit checks all 90 tests on the server, hidden ones included.