"Title description"
Handsome often play with classmates a matrix take number game: for a given n*m matrix, each element of the matrix A[i,j] are
is a non-negative integer. The rules of the game are as follows:
1. Each fetch must take one element from each row, a total of n. After M times, all elements of the matrix are taken out;
2. Each element taken away can only be the beginning or end of the line where the element is located;
3. Each fetch has a score value, the sum of the scores for each row, the number of points per row = The value of the element taken away *2^i,
Where I is the number of times I fetch (numbering starting from 1);
4. The end of the game must be divided into M-time score of the sum.
Handsome want to ask you to help write a program, for any matrix, you can find out the maximum score after the number.
"Input description"
1th Act two integers separated by spaces N and M.
The 2nd to n+1 behavior n*m matrix, where each row has m a non-negative integer separated by a single space.
"Output description"
Contains only 1 rows, an integer, which is the maximum score after the input matrix is taken.
"Sample Input"
2 3
1 2 3
3 4 2
"Sample Output"
82
"Data range and Tips"
Sample explanation:
1th time: The 1th row takes the beginning element, the 2nd line takes the line tail element, this time the score is 1*2^1+2*2^1=6;
2nd time: Both lines take the beginning of the element, the score is 2*2^2+3*2^2=20;
3rd time: Score is 3*2^3+4*2^3=56. Must be divided into 6+20+56=82.
60% of the data meet: 1 <= n,m <= 30, the answer is not more than 10^16;
100% data satisfies: 1 <= n,m <= 80,0 <= a[i,j] <= 1000.
Matrix Fetch Games