zoukankan      html  css  js  c++  java
  • Gym 102056I

    Warm sunshine, cool wind and a fine day, while the girl watching is pursuing in chaos. Rikka reached out her hand and got the garland on her head, finding LCR with the immortal smile. The dream ended up waking, but the doubts will never disappear. In the end, without knowing about LCR, Rikka was invited to Shuyuan Men, a street of Chinese traditional arts in Xi'an.

    "Is it enough to use the stored wires?"

    "No problem... Those leaders are only concerned about expanding EC Final for the school's and their 'achievements'. All chores are ours. It is fine to simply connect those wiring boards in the series for each row."

    Their conversation engaged Rikka. Feeling strange, she decided to follow them. But before all, she needs to beat the devil in her heart.

    Rikka has an aggressivity AA and an increment DD of it, which are both 00initially. There are nn rounds in total. For i=1,2,,ni=1,2,…,n, at the beginning of ii-th round Rikka's aggressivity AA increases by the increment DD, and then she can do one of the following:

    Attack and cause a damage of (A+ai)(A+ai).
    Use the Omnipotent Garland from LCR to increase the increment DD by bibi.
    Use her Schwarz Sechs Prototype Mark II to increase the aggressivity AA by cici.
    Rikka wonders the maximal possible damage she could cause in total. Could you help her?

    Input
    The first line contains a single integer T(1T10)T(1≤T≤10), the number of test cases. Then TT test cases follow.

    The input format of each test case is as follows:

    The first line contains a single integer n(1n100)n(1≤n≤100), the number of rounds.

    The following nn lines contain ai,bi,ciai,bi,ci for i=1,2,,ni=1,2,…,n. The ii-th line among them contains three integers ai,bi,ci(1ai,bi,ci109)ai,bi,ci(1≤ai,bi,ci≤109) separated by spaces in order.

    It is guaranteed that the sum of nn in all test cases is at most 100.

    Output
    Output T lines; each line contains one integer, the answer to that test case.

    Example
    input
    3
    2
    3 1 2
    3 1 2
    3
    3 1 2
    3 1 2
    3 1 2
    5
    3 1 2
    3 1 2
    3 1 2
    3 1 2
    3 1 2
    output
    6
    10
    24

     

    题意:

    打怪,有 AA 的攻击力,有 DD 的成长,初始均为 00,有 nn 轮。

    同时有三个数组 a[1:n],b[1:n],c[1:n]a[1:n],b[1:n],c[1:n]。

    对于每一轮:

      首先,攻击力永久性成长 A=A+DA=A+D;然后,在下面三个选择中选择一种行为:

      ①、发起进攻,产生 A+aiA+ai 的伤害。

      ②、增加成长 D=D+biD=D+bi。

      ③、永久性增加攻击力 A=A+ciA=A+ci。

    问产生最大总伤害为多少。








    发现如果要是正向dp的话是由后效性的,需要存储的当前的a和d的值,而两个的值都是1e9,所以说不能这么做,

    然后就可以反向的dp,考虑每个觉得影响这样就不需要存储a和d的状态了

    具体看一下别的题解吧,都写得挺清楚的。

    然后就是需要滚动数组,空间开不下。




     1 #include"bits/stdc++.h"
     2 using namespace std;
     3 
     4 typedef long long ll;
     5 struct aa
     6 {
     7     int a,b,c;
     8 }a[1200];
     9 
    10 ll dp[3][120][6000];
    11 
    12 int now=1,pre=0;
    13 int main()
    14 {   int n;
    15    int T;cin>>T;
    16    while(T--)
    17    {
    18           cin>>n;
    19           now=1,pre=0;   int l=n,r=(n+1)*n/2;
    20           
    21           for (int i=1;i<=n;i++)
    22           {
    23             cin>>a[i].a>>a[i].b>>a[i].c;    
    24        }
    25        memset(dp,-1,sizeof dp);  dp[0][1][n]=a[n].a;
    26        
    27        for (int i=n-1;i;i--)
    28        {
    29             for (int j=n;j;j--)
    30             {
    31                   for (int k=r;k>=l;k--)
    32                   {
    33                         ll t=-1;
    34                   if(j-1>=0&&k-i>=0&&dp[pre][j-1][k-i]!=-1)t=max(t,dp[pre][j-1][k-i]+a[i].a);
    35                   if(dp[pre][j][k]!=-1)t=max(t,dp[pre][j][k] +j*a[i].c),
    36                   t=max(t,dp[pre][j][k]+ a[i].b*(k-j*i));
    37                  dp[now][j][k]=t;    
    38              }
    39                
    40          }
    41          swap(now,pre);
    42        }
    43        //cout<<<"Now: "<<dp[pre][2][]
    44         ll ans=0; 
    45        for (int i=1;i<=n;i++)
    46         for (int j=1;j<=r;j++)ans=max(ans,dp[pre][i][j]);
    47         cout<<ans<<endl;
    48        
    49        
    50    }    
    51     
    52 }

     

  • 相关阅读:
    链式队列(先进先出)
    单链表的基本操作
    线性表的基本操作
    面向对象分析与设计
    结构化分析与设计
    图片
    2021-ACM-ICPC-济南站 K Search For Mafuyu 【树的遍历与回溯,dfs, 邻接表】
    Codeforces Round #754 (Div. 2), problem: (A) A.M. Deviation泪目 万万没想到狂wa是因为这
    Codeforces Round #704 (Div. 2), problem: (C) Maximum width还是要多学习
    Educational Codeforces Round 116 (Rated for Div. 2), problem: (C) Banknotes
  • 原文地址:https://www.cnblogs.com/zhangbuang/p/10661062.html
Copyright © 2011-2022 走看看