Stupid Tower Defense

Source: Internet
Author: User

Topic links

    • Test instructions
      n 1*1 in the horizontal direction, each lattice can grow a plant, passing a lattice time is t. Altogether three kinds of plants: R plants. R point damage received per second after passing, G plant, G-point damage per second after passing, b plant, after passing through a lattice time plus B
      2<=n<=1500,0<=r, G, b<=60000,1<=t<=3
    • Analysis:
      The most beginning to consider the greedy: first b plants, after g plants, finally B plants. Later found to be wrong.
      First, it is clear that r plants have no effect on the location of the answer, whereas B and G plants grow better early, so the problem lies in the methods of B and G.


      The status is expressed to be clear, regardless of the position of G and B. The subsequent situation is only related to the number of B and G. So can DP. DP[I][J] indicates that the total damage of the plant is now a b plant, J G. can be greedy. Implementation of one-dimensional DP processing

LL N, G, B, r, T;    LL Dp[maxn];int Main () {int T;    RI (T);        FE (Kase, 1, T) {cin >> n >> R >> G >> b >> T;        LL ans = n * r * t; CLR (DP,-1);        Dp[0] = 0; REP (all, N) {FED (i, n, 0) {if (~dp[i]) {L                    L NXT = Dp[i] + (i * b + t) * (all-i) * g;                    if (Dp[i + 1] < NXT) Dp[i + 1] = NXT;                    NXT = Dp[i] + (i * b + t) * (all-i) * g;                if (Dp[i] < NXT) Dp[i] = NXT;  }} FE (i, 0, N) {if (~dp[i]) {LL NXT =                    Dp[i] + (N-ALL-1) * (t + i * b) * (R + (all + 1-i) * g);                if (ans < nxt) ans = nxt;    }}} printf ("Case #%d:%i64d\n", Kase, ans); } return 0;}


Stupid Tower Defense

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.