Codeforces 855B Marvolo Gaunt's Ring

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces 855B Marvolo Gaunt's Ring相关的知识,希望对你有一定的参考价值。

二次联通门 : Codeforces 855B Marvolo Gaunt‘s Ring

 

 

 

 

/*
    Codeforces 855B Marvolo Gaunt‘s Ring
    
    SB dp
    然后WA了三发才过
    原因是极大值太小了
    INF = 1e9 = WA
    INF = 1e18 = WA
    INF = 8e18 = AC
*/
#include <cstdio>
#define INF 8e18
#define Max 123123
#define rg register
typedef long long LL; LL f[Max], v[Max];
inline void cmax (LL &a, LL b) { if (b > a) a = b; }
inline LL max (LL a, LL b) { return a > b ? a : b; }
int main (int argc, char *argv[])
{
    LL N, p, q, r; scanf ("%lld%lld%lld%lld", &N, &p, &q, &r); rg int i, j;
    f[0] = -INF; LL s = -INF;
    for (i = 1; i <= N; ++ i)
        scanf ("%lld", &v[i]), f[i] = max (f[i - 1], p * v[i]);
    for (i = 1; i <= N; ++ i)
        f[i] = max (f[i - 1], f[i] + q * v[i]);
    for (i = 1; i <= N; ++ i)
        f[i] = max (f[i - 1], f[i] + r * v[i]), cmax (s, f[i]);
    printf ("%lld", s); return 0;
}

 

以上是关于Codeforces 855B Marvolo Gaunt's Ring的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces 855B Marvolo Gaunt's Ring

Codeforces 855B - Marvolo Gaunt's Ring

Codeforces 855B 简单DP

CodeForces - 855B ring 前缀和

B Marvolo Gaunt's Ring

CodeForce 855B 暴力or线段树