It means there is a tower defense game with three types of towers. When a monster passes through the tower, it will cause damage to the attacking power every second. The tower will cause damage to the attacking power every second after the monster passes through the game, there is also a blue tower to slow down the monsters, that is, the monsters will slow down C seconds after a Unit
What is the maximum damage value?
I didn't think about it again when I was playing the game. I knew it was a DP, but it was a little cool for this multi-variable DP. This idea is similar. First, you must enumerate one or two values.
Here we have a feature: the better the front of the Green Tower and the blue Tower, the better the back of the Red Tower (mainly the front of the tower to the other two). This uses a greedy technique, but it is absolutely right.
So we can enumerate all the dots behind them... What should I do with the Green Tower and the blue tower. At this time, we can't think about the whole world. Consider the damage of a single point. The front is green and blue, and the back is red. In this way, I will enumerate the number of blue towers in front of it, then the Green Tower is the length-the number of blue, so that the point of the damage I can find out, and then through the I-1 transition out, you can get the entire front of the injury, then, by directly calculating the damage caused by the red tower, you can obtain the total damage in this state, and finally obtain the maximum value.
# Include <iostream> # include <cstdio> # include <cstring> # define ll _ int64using namespace STD; ll DP [1510] [1510]; int main () {int W, Kase = 0; ll n, x, y, z, T; scanf ("% d", & W); While (w --) {memset (DP, 0, sizeof DP); scanf ("% i64d % i64d % i64d % i64d % i64d", & N, & X, & Y, & Z, & T ); ll ans = 0; For (INT I = 1; I <= N; I ++) {for (Int J = 0; j <= I; j ++) {If (j <I) DP [I] [J] = DP [I-1] [J] + (i-1-j) * z + T) * j * Y; if (j> 0) {DP [I] [J] = max (DP [I] [J], DP [I-1] [J-1] + (I-j) * z + T) * (J-1) * Y);} ans = max (ANS, DP [I] [J] + (I-j) * z + T) * (N-I) * (x + J * y);} ans = max (ANS, N * T * X); printf ("case # % d: ", ++ Kase); printf (" % i64d \ n ", ANS );}}
Hdu_4939 stupid tower defense 2014 multi-school 7 multi-variable DP