#P1544. 三倍经验
三倍经验
Description
A number pyramid has rows of integers. The -th row () has numbers. One example is as follows.
7
3 9
8 1 0
2 7 4 4
4 5 2 6 5
Now you start at the top of the pyramid (the first row) and want to reach the bottom (the -th row). At each step, you can move to the number down-left or down-right of your current position. Also, as a powerful kid, you may choose at most numbers in the pyramid and make them times their original value.
You will collect all numbers along your path. Your final score is the sum of the collected numbers. Find the maximum possible score.
Input Format
The first line contains two integers , the number of rows in the number pyramid and the maximum count of numbers that can be multiplied by .
Then follow lines. The -th of them contains space-separated integers, which are the numbers in the -th row of the pyramid: .
Output Format
Output a single integer, the maximum score.
5 3
7
3 9
8 1 0
2 7 4 4
4 5 2 6 5
75
Hint
Constraints:
For of the testdata, , and for any , it holds that .
For of the testdata, , , and for any , it holds that .
Translated by ChatGPT 5
京公网安备 11011102002149号