結果

問題 No.1104 オンライン点呼
ユーザー tokusakuraitokusakurai
提出日時 2020-07-03 22:09:14
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,208 bytes
コンパイル時間 1,746 ms
コンパイル使用メモリ 166,672 KB
実行使用メモリ 5,760 KB
最終ジャッジ日時 2024-09-17 02:23:53
合計ジャッジ時間 3,896 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N; ll K;
    cin >> N >> K;
    ll A[N], B[N];
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    if(N == 0) {cout << 0 << endl; return 0;}
    ll t[N];
    t[0] = 0;
    t[1] = t[0]+A[0]+B[1];
    rep2(i, 2, N-1){
        t[i] = min(t[i-1]+A[i-1]+B[i], t[i-2]+A[i-2]+B[i]+K);
    }
    ll ans = 0;
    rep(i, N) chmax(ans, t[i]);
    cout << ans << endl;
}
0