結果

問題 No.1104 オンライン点呼
ユーザー chocoruskchocorusk
提出日時 2020-07-03 22:30:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 944 bytes
コンパイル時間 1,177 ms
コンパイル使用メモリ 126,512 KB
実行使用メモリ 5,856 KB
最終ジャッジ日時 2023-10-17 05:28:38
合計ジャッジ時間 3,292 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 82 ms
5,856 KB
testcase_02 AC 76 ms
5,856 KB
testcase_03 AC 55 ms
5,856 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
4,880 KB
testcase_08 AC 14 ms
4,348 KB
testcase_09 AC 31 ms
5,748 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 22 ms
4,468 KB
testcase_12 AC 34 ms
4,920 KB
testcase_13 AC 28 ms
4,352 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 45 ms
5,028 KB
testcase_16 AC 50 ms
5,540 KB
testcase_17 AC 32 ms
4,676 KB
testcase_18 AC 42 ms
5,032 KB
testcase_19 AC 63 ms
5,432 KB
testcase_20 AC 67 ms
5,588 KB
testcase_21 AC 68 ms
5,608 KB
testcase_22 AC 56 ms
5,236 KB
testcase_23 AC 44 ms
4,860 KB
testcase_24 AC 19 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
    ll k;
    cin>>n>>k;
    ll a[100010], b[100010];
    for(int i=0; i<n; i++) cin>>a[i];
    for(int i=0; i<n; i++) cin>>b[i];
    ll dp[100010];
    dp[0]=0;
    for(int i=1; i<n; i++){
        dp[i]=dp[i-1]+a[i-1]+b[i];
        if(i-2>=0) dp[i]=min(dp[i], dp[i-2]+a[i-2]+b[i]+k);
    }
    ll ans=dp[n-1];
    if(n-2>=0) ans=max(ans, dp[n-2]);
    cout<<ans<<endl;
	return 0;
}
0