結果

問題 No.1104 オンライン点呼
ユーザー betrue12
提出日時 2020-07-03 21:50:13
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 483 bytes
コンパイル時間 3,082 ms
コンパイル使用メモリ 194,340 KB
最終ジャッジ日時 2025-01-11 14:27:35
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int64_t> A(N), B(N);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N; i++) cin >> B[i];
    vector<int64_t> dp(N);
    dp[0] = 0;
    for(int i=1; i<N; i++){
        dp[i] = dp[i-1] + A[i-1] + B[i];
        if(i > 2) dp[i] = min(dp[i], dp[i-2] + A[i-2] + B[i] + K);
    }
    int64_t ans = *max_element(dp.begin(), dp.end());
    cout << ans << endl;
    return 0;
}
0