码迷,mamicode.com
首页 > 其他好文 > 详细

Codeforces 855B Marvolo Gaunt's Ring

时间:2017-09-27 20:41:23      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:code   .com   long   target   logs   clu   log   pre   scanf   

二次联通门 : 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

标签:code   .com   long   target   logs   clu   log   pre   scanf   

原文地址:http://www.cnblogs.com/ZlycerQan/p/7603397.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!