結果

問題 No.1104 オンライン点呼
ユーザー betrue12betrue12
提出日時 2020-07-03 21:50:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 483 bytes
コンパイル時間 2,043 ms
コンパイル使用メモリ 206,632 KB
実行使用メモリ 5,712 KB
最終ジャッジ日時 2023-10-17 00:38:39
合計ジャッジ時間 4,337 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 84 ms
5,712 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 31 ms
5,448 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 44 ms
4,920 KB
testcase_16 WA -
testcase_17 AC 32 ms
4,392 KB
testcase_18 AC 41 ms
4,920 KB
testcase_19 AC 63 ms
5,184 KB
testcase_20 AC 67 ms
5,448 KB
testcase_21 AC 67 ms
5,448 KB
testcase_22 AC 56 ms
5,184 KB
testcase_23 AC 44 ms
4,656 KB
testcase_24 AC 20 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 3 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

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