#graph804. k 取方格数
k 取方格数
Grid Number Picking (k Paths)
Problem Description
You are given an matrix where each cell holds a non-negative integer . Starting from you may move only right or down to reach ; upon reaching a cell you take its number and that cell's value becomes . You repeat this walk times. For each , find the maximum possible sum of the numbers taken over walks.
Input Format
The first line contains one integer .
The next lines each contain integers, the values of the matrix cells.
Output Format
Output lines, the answer for in order.
Sample Input
3
1 2 3
0 2 1
1 4 2
Sample Output
11
15
16