#P3800. Power 收集
Power 收集
Description
Treat the game screen as an -row by -column grid. There are P points on cells, and their values are .
Initially, Reimu may choose any cell in the first row to start. Each second, she must move down by exactly one row.
Reimu has a horizontal speed , allowing her each second to move left or right by at most columns, or not move horizontally at all, and she cannot reverse direction within a single move. Movement is considered instantaneous: she does not pass through intermediate cells en route and can only obtain the P point on the destination cell.
Compute the maximum possible total value of all P points she can obtain.
Input Format
The first line contains four integers, .
Each of the next lines contains three integers , indicating that there is a P point with at row , column . It is guaranteed that there is at most P point on any cell.
Output Format
Output a single integer, the maximum total value of P points Reimu can obtain.
3 3 4 1
1 1 3
1 2 1
2 2 3
3 3 3
9
Hint
For of the testdata, .
For of the testdata, , , and are all integers.
by-szc
Translated by ChatGPT 5
京公网安备 11011102002149号