結果

問題 No.1375 Divide and Update
ユーザー auauaauaua
提出日時 2021-02-05 22:37:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 1,627 bytes
コンパイル時間 1,768 ms
コンパイル使用メモリ 170,844 KB
実行使用メモリ 17,336 KB
最終ジャッジ日時 2023-09-15 09:09:02
合計ジャッジ時間 5,519 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,500 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 113 ms
15,320 KB
testcase_11 AC 104 ms
14,336 KB
testcase_12 AC 57 ms
9,140 KB
testcase_13 AC 48 ms
8,268 KB
testcase_14 AC 129 ms
17,080 KB
testcase_15 AC 130 ms
16,996 KB
testcase_16 AC 130 ms
17,336 KB
testcase_17 AC 129 ms
17,204 KB
testcase_18 AC 137 ms
16,992 KB
testcase_19 AC 138 ms
17,004 KB
testcase_20 AC 84 ms
17,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> Complex;
const ll INF=1e9+7;
const ll inf=INF*INF;
const ll mod=998244353;
const ll MAX=140010;



signed main(){
    ll n,x,y;cin>>n>>x>>y;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<ll>ans(n);
    {
    vector<vector<ll> >dp(n,vector<ll>(3));
    dp[0][0]=a[0];
    dp[0][1]=x;
    dp[0][2]=0;
    REP(i,1,n){
        dp[i][0]=dp[i-1][0]+a[i];
        dp[i][1]=max(dp[i-1][0]+x,dp[i-1][1]+x);
        dp[i][2]=max(dp[i-1][2]+a[i],dp[i-1][1]+a[i]);
    }
    REP(i,1,n-1){
        ll ma=0;
        REP(j,1,3){
            ma=max(ma,dp[i-1][j]);
        }
        ans[i]+=ma;
    }
    }
    {
        reverse(all(a));
        x=y;
        vector<vector<ll> >dp(n,vector<ll>(3));
    dp[0][0]=a[0];
    dp[0][1]=x;
    dp[0][2]=0;
    REP(i,1,n){
        dp[i][0]=dp[i-1][0]+a[i];
        dp[i][1]=max(dp[i-1][0]+x,dp[i-1][1]+x);
        dp[i][2]=max(dp[i-1][2]+a[i],dp[i-1][1]+a[i]);
    }
    reverse(all(dp));
    REP(i,1,n-1){
        ll ma=0;
        REP(j,1,3){
            ma=max(ma,dp[i+1][j]);
        }
        ans[i]+=ma;
    }

    }
    reverse(all(a));
    REP(i,1,n-1){
        cout<<a[i]+ans[i]<<endl;
    }
}
0