#P2795. Facer爱游泳
Facer爱游泳
Description
One day he came to an swimming pool, where the first row is the water surface and the -th row is the bottom of the pool.

Facer wants to swim from to . His initial speed is m/s.
Facer can swim as follows: suppose Facer is currently at with speed , then he can swim to . If , he will instead swim to .
Upon reaching each cell, Facer can choose to change his speed by , , or keep it unchanged. That is, each time Facer has three choices:
- Swim to and the speed becomes .
- Swim to and the speed becomes .
- Swim to and the speed becomes .
Each cell in the swimming pool contains exactly one of the following two items:
- Accelerator: each accelerator has an attribute . Upon reaching this cell, the speed becomes (of course, the original options of , , or unchanged still apply).
- Coin box: each coin box contains an amount . Upon reaching this cell, you obtain coins.
In addition, note the following:
- When Facer reaches the surface, i.e., is at , Facer’s speed becomes (he can still choose to change his speed by , , or keep it unchanged).
- Facer cannot stay underwater for too long. The time between two consecutive surfacings cannot exceed seconds.
Find the maximum number of coins Facer can obtain.
Input Format
The first line contains three integers .
From the second line to line , each line contains strings describing the item in each cell:
- If the first character is
vfollowed by an integer , then the cell contains an accelerator with attribute . - If the first character is
sfollowed by an integer , then the cell contains a coin box with amount .
Output Format
Output a single integer, the answer.
3 3 3
s1 v1 s1
s3 s19 v2
v3 s-1 v-1
2
5 10 3
s81 s47 s3 s0 s82 s31 s89 v0 s97 v-1
s14 s94 v1 v-1 v1 s106 v1 v0 v-1 v0
s93 s105 v-1 s219 v0 v0 v-1 v1 s225 v1
v0 s160 v1 v1 s348 s120 s240 s392 s280 s172
s305 s455 s140 v-1 s455 v0 v-1 v0 v1 s410
430
Hint
Constraints
- For of the testdata, .
- For of the testdata, .
- For of the testdata, , , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号