結果

問題 No.1375 Divide and Update
ユーザー snow39snow39
提出日時 2021-02-05 22:17:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 1,399 bytes
コンパイル時間 905 ms
コンパイル使用メモリ 99,116 KB
実行使用メモリ 26,836 KB
最終ジャッジ日時 2023-09-15 08:32:41
合計ジャッジ時間 4,044 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 72 ms
23,432 KB
testcase_11 AC 66 ms
21,780 KB
testcase_12 AC 37 ms
13,448 KB
testcase_13 AC 32 ms
11,544 KB
testcase_14 AC 81 ms
26,752 KB
testcase_15 AC 81 ms
26,452 KB
testcase_16 AC 81 ms
26,364 KB
testcase_17 AC 82 ms
26,836 KB
testcase_18 AC 80 ms
26,516 KB
testcase_19 AC 81 ms
26,556 KB
testcase_20 AC 67 ms
26,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

const ll INF=1e18;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  ll X,Y;
  cin>>N>>X>>Y;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];

  vector<vector<ll>> ldp(N+1,vector<ll> (3,-INF));
  vector<vector<ll>> rdp(N+1,vector<ll> (3,-INF));
  rep(t,2){
    ldp[0][0]=0;
    for(int i=0;i<N;i++){
      for(int j=0;j<=2;j++){
        ll value=ldp[i][j];
        if(value==-INF) continue;
        if(j==0){
          chmax(ldp[i+1][2],value+X);
          chmax(ldp[i+1][1],value+X);
          chmax(ldp[i+1][0],value+A[i]);
        }else if(j==1){
          chmax(ldp[i+1][2],value+max(X,A[i]));
          chmax(ldp[i+1][1],value+X);
        }else{
          chmax(ldp[i+1][2],value+A[i]);
        }
      }
    }
    swap(ldp,rdp);
    swap(X,Y);
    reverse(all(A));
  }
  reverse(all(rdp));

  for(int i=1;i<N-1;i++){
    ll ans=ldp[i][2]+rdp[i+1][2]+A[i];
    cout<<ans<<"\n";
  }

  return 0;
}
0