Each list in piles describes a nonempty stack of coins from top to bottom. In one move, remove the top coin from any nonempty pile and add its value to your total. Return the largest total value obtainable by removing exactly k coins. A coin deeper in a pile is available only after all coins above it have been removed.
Example 1:
Input: piles = [[2,20],[10]]
k = 2
Output: 22Explanation: Take the first two coins from the first pile for a total of 2 + 20 = 22. Taking one coin from each pile gives only 12.
Example 2:
Input: piles = [[5],[7,1]]
k = 3
Output: 13Explanation: Exactly three coins must be taken, and there are three available. Their values sum to 5 + 7 + 1 = 13.
Example 3:
Input: piles = [[1,100],[9]]
k = 1
Output: 9Explanation: Only the top coins, 1 and 9, are immediately available. Choose 9; reaching the coin worth 100 would require two removals.
Constraints:
1 <= piles.length <= 1000- Each pile is nonempty.
1 <= piles[i][j] <= 1000001 <= k <=the total number of coins<= 2000.