#P1005. [NOIP 2007 提高组] 矩阵取数游戏

    ID: 5 远端评测题 1000ms 125MiB 尝试: 1 已通过: 1 难度: 6 上传者: 标签>动态规划,dp高精度2007NOIp 提高组进制

[NOIP 2007 提高组] 矩阵取数游戏

Description

Shuai Shuai often plays a matrix number picking game with classmates: given an n×mn \times m matrix where each element ai,ja_{i,j} is a non-negative integer, the game rules are as follows:

  1. In each round, exactly one element is taken from each row, for a total of nn elements. After mm rounds, all elements in the matrix are taken.
  2. Each taken element must be either the leftmost or the rightmost element of its row.
  3. The score of each round is the sum of the per-row scores. The per-row score equals the value of the taken element ×2i\times 2^i, where ii denotes the ii-th round (starting from 11).
  4. The total score of the game is the sum of the scores over all mm rounds.

Please write a program that, for any given matrix, computes the maximum possible total score.

Input Format

The input consists of n+1n+1 lines.

  • The first line contains two integers nn and mm separated by a space.
  • Lines 22 to n+1n+1 contain the n×mn \times m matrix. Each line has mm non-negative integers separated by single spaces.

Output Format

Output a single line containing one integer: the maximum possible total score.

2 3
1 2 3
3 4 2

82

Hint

  • Constraints:
    • For 60%60\% of the testdata, 1n,m301 \le n, m \le 30, and the answer does not exceed 101610^{16}.
    • For 100%100\% of the testdata, 1n,m801 \le n, m \le 80, 0ai,j10000 \le a_{i,j} \le 1000.
  • Source: NOIP 2007 Senior, Problem 3.

Translated by ChatGPT 5