• 2236 Kaka's Matrix Travels

    时间限制 : 2000/1000 MS(Java/Others) | 内存限制 : 131072/65536 KB(Java/Others)

    提交数 : 36 | 通过数 : 7

    题目描述

    On an N × N chessboard with a non-negative number in each grid, Kaka starts his matrix travels with SUM = 0. For each travel, Kaka moves one rook from the left-upper grid to the right-bottom one, taking care that the rook moves only to the right or down. Kaka adds the number to SUM in each grid the rook visited, and replaces it with zero. It is not difficult to know the maximum SUM Kaka can obtain for his first travel. Now Kaka is wondering what is the maximum SUM he can obtain after his Kth travel. Note the SUM is accumulative during the K travels.

    输入要求

    The first line contains two integers N and K (1 ≤ N ≤ 50, 0 ≤ K ≤ 10) described above. The following N lines represents the matrix. You can assume the numbers in the matrix are no more than 1000.

    输出要求

    The maximum SUM Kaka can obtain after his Kth travel.

    输入样例

    3 2
    1 2 3
    0 2 1
    1 4 2
    

    输出样例

    15

    提示


    来源

    POJ Monthly--2007.10.06, Huang, Jinsong

    [ 返回顶端 ] | [ 代码提交 ] | [ 统计数据 ] | [ 历史提交 ]