結果
問題 | No.1375 Divide and Update |
ユーザー | snow39 |
提出日時 | 2021-02-05 22:13:46 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,375 bytes |
コンパイル時間 | 894 ms |
コンパイル使用メモリ | 97,732 KB |
実行使用メモリ | 26,684 KB |
最終ジャッジ日時 | 2023-09-15 08:27:03 |
合計ジャッジ時間 | 3,571 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | WA | - |
testcase_04 | AC | 2 ms
4,384 KB |
testcase_05 | WA | - |
testcase_06 | AC | 1 ms
4,384 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 70 ms
23,524 KB |
testcase_11 | AC | 65 ms
21,696 KB |
testcase_12 | AC | 37 ms
13,400 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 66 ms
26,468 KB |
ソースコード
#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(j==0){ chmax(ldp[i+1][2],value+X); chmax(ldp[i+1][1],value+max(X,A[i])); 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; }