Hdu4939stupid tower defense (thoughtful DP)

Source: Internet
Author: User
Stupid tower defense Time Limit: 12000/6000 MS (Java/others) memory limit: 131072/131072 K (Java/Others)
Total submission (s): 1557 accepted submission (s): 445


Problem descriptionfsf is addicted to a stupid tower defense game. the goal of tower Defense Games is to try to stop enemies from crossing a map by building traps to slow them down and towers which shoot at them as they pass.

The map is a line, which has n unit length. we can build only one tower on each unit length. the enemy takes t seconds on each unit length. and there are 3 kinds of tower in this game: The Red Tower, the Green Tower and the blue tower.

The Red Tower damage on the enemy X points per second when he passes through the tower.

The Green Tower damage on the enemy y points per second after he passes through the tower.

The blue tower let the enemy go slower than before (that is, the enemy takes more Z second to pass an unit length, also, after he passes through the tower .)

Of course, if you are already pass through M green towers, you shoshould have got M * y damage per second. the same, if you are already pass through K blue towers, the enemy shoshould have took T + K * z seconds every unit length.

FSF now wants to know the maximum damage the enemy can get.
Inputthere are multiply test cases.

The first line contains an integer T (t <= 100), indicates the number of cases.

Each test only contain 5 integers n, x, y, z, T (2 <= n <= 1500,0 <= x, y, z <= 60000,1 <= T <= 3)

Outputfor each case, You shoshould output "case # C:" First, where C indicates the case number and counts from 1. then output the answer. for each test only one line which have one integer, the answer to this question.
Sample Input
12 4 3 2 1

Sample output
Case #1: 12HintFor the first sample, the first tower is blue tower, and the second is red tower. So, the total damage is 4*(1+2)=12 damage points. 

Authoruestc
Source2014 multi-university training contest 7 analysis: The Red Tower only strikes the people who have passed the tower, the Green Tower makes the passing of all the following towers, and the basketball tower only takes a long time to go through the tower, suppose there are n towers, e green towers, J basket towers, K red towers, n = e + J + K; the Red Tower only performs a power attack on the current person wherever it is placed. If you want to maximize the power of the current man, all the red towers must be placed at the end. Now you only need to list the number of E and J in the list, k = n-e-J; k red towers are all placed at the end. If DP [I] [J] is set, the previous I tower has the primary impact value of J basket towers.
# Include <stdio. h> # include <string. h> # define ll _ int64ll DP [1505] [1505]; int main () {ll t, n, x, y, z, T, ANS, c = 0, AA; For (INT I = 0; I <= 1500; I ++) DP [0] [I] = 0; scanf ("% i64d", & T ); while (t --) {scanf ("% i64d % i64d % i64d % i64d", & N, & X, & Y, & Z, & T ); ans = N * T * X; For (ll I = 1; I <= N; I ++) for (ll j = 0; j <= I; j ++) {DP [I] [J] = DP [I-1] [J] + (i-1-j) * (J * z + T) * Y; // the I-th tower is the Green Tower if (j> 0) {AA = DP [I-1] [J-1] + (I-j) * (J-1) * z + T) * Y; // the I-th tower is the basket tower if (DP [I] [J] <aa) DP [I] [J] = AA ;} AA = DP [I] [J] + (I-j) * Y + x) * (J * z + T) * (N-I ); // Add the power strike value of the Red Tower (from the front tower and itself) if (AA> ans) ans = AA;} printf ("case # % i64d: % i64d \ n ", ++ C, ANS );}}


Hdu4939stupid tower defense (thoughtful DP)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.