#P3257. [JLOI2014] 天天酷跑
[JLOI2014] 天天酷跑
Description
In the game Tiantian Cool Run, the most exciting part is probably the Super Bonus mode, where there are no obstacles and you can freely collect coins. Now you are to control the character to obtain as high a score as possible. The game interface is discretized into a grid with length from to and height from to (the starting point is ). Every cell has a gain in the range , where means the cell is impassable. The character runs from the start to the finish; along the way, they can jump to get a higher score, and can even perform consecutive jumps while in midair.
Before the game starts, you may set the jump height and the number of consecutive jumps. The initial jump height is , and the initial number of consecutive jumps is (up to a maximum of ). Upgrading jump height and the number of consecutive jumps both require a certain cost. Once the jump height is set, every jump will use this fixed height. A consecutive jump can only be used while descending. All actions happen at integer time steps. You must ensure that with the set jump height and number of consecutive jumps, the character cannot jump above the top boundary of the game.

From , using one jump, the path passes through .
Below is a jumping plan with the number of consecutive jumps equal to and jump height equal to :

Starting to jump from , the path goes through , then uses a consecutive jump and passes through .

Input Format
The first line contains four integers . Here are as described above, and respectively denote the cost to increase the jump height by level and the cost to increase the number of consecutive jumps by .
Then follow lines, each containing integers. The integer in the -th row and -th column gives the gain at height and length in the map.
Output Format
If it is impossible to reach the finish line, output mission failed. Otherwise, output one line with three integers: the maximum gain; among all settings achieving the maximum gain, the minimum number of consecutive jumps; and among those, the minimum jump height.
7 4 6 10
9 4 7 7 4 3 2
18 8 9 4 15 12 4
19 2 4 7 10 18 12
8 1 13 14 16 0 14
67 1 2
Hint
For of the testdata, and .
For the remaining of the testdata, , . Among them, for of the testdata it is guaranteed that , .
Translated by ChatGPT 5
京公网安备 11011102002149号