結果

問題 No.1104 オンライン点呼
ユーザー ShibuyapShibuyap
提出日時 2020-07-03 21:55:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 829 bytes
コンパイル時間 1,925 ms
コンパイル使用メモリ 202,352 KB
実行使用メモリ 6,764 KB
最終ジャッジ日時 2023-10-17 02:03:53
合計ジャッジ時間 4,316 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 82 ms
6,764 KB
testcase_02 AC 76 ms
6,760 KB
testcase_03 AC 55 ms
6,764 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 32 ms
5,444 KB
testcase_08 WA -
testcase_09 AC 31 ms
6,600 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 22 ms
4,892 KB
testcase_12 AC 33 ms
5,496 KB
testcase_13 AC 28 ms
4,740 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 45 ms
5,640 KB
testcase_16 AC 51 ms
6,324 KB
testcase_17 AC 32 ms
5,172 KB
testcase_18 AC 41 ms
5,644 KB
testcase_19 AC 62 ms
6,176 KB
testcase_20 AC 66 ms
6,388 KB
testcase_21 AC 68 ms
6,416 KB
testcase_22 AC 56 ms
5,916 KB
testcase_23 AC 44 ms
5,416 KB
testcase_24 AC 20 ms
4,392 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("YES");}else{puts("NO");}
#define MAX_N 200005

int main() {
    ll n, k;
    cin >> n >> k;
    ll a[n], b[n];
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];

    ll dp[n][2];
    rep(i,n)rep(j,2)dp[i][j] = 0;

    rep(i,n){
        if(i == 0){
            dp[i][1] = a[i];
        }else if(i == 1){
            dp[i][0] = dp[i-1][1] + b[i];
            dp[i][1] = dp[i][0] + a[i];
        }else{
            dp[i][0] = min(dp[i-1][1], dp[i-2][1]+k) + b[i];
            dp[i][1] = dp[i][0] + a[i];
        }
    }

    cout << dp[n-1][0] << endl;
    return 0;
}
 
 
0