結果

問題 No.1104 オンライン点呼
ユーザー ngtkana
提出日時 2020-05-16 08:58:41
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 1,343 bytes
コンパイル時間 2,131 ms
コンパイル使用メモリ 196,104 KB
最終ジャッジ日時 2025-01-10 12:20:50
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#define ENABLE_DEBUG 0
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(lint ngtkana_is_a_genius=0; ngtkana_is_a_genius<(lint)k; ngtkana_is_a_genius++)
using lint=long long;
using ld=long double;

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template<class T> using numr=std::numeric_limits<T>;
struct input_t {
    template<class T> operator T() {
        T t;
        std::cin>>t;
        return t;
    }
} input;
#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/
auto cmn=[](auto&x,auto y){if(x>y){x=y;return true;}return false;};
int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    usize n; i64 k;
    std::cin >> n >> k;

    i64 inf = numr<i64>::max();
    std::vector<i64> a(n), b(n), time(n, inf);
    for (i64& x: a) std::cin >> x;
    for (i64& x: b) std::cin >> x;
    time.at(0) = 0;

    for (usize i=1; i<n; i++) {
        time.at(i) = time.at(i-1)+a.at(i-1)+b.at(i);
        if (1<i) cmn(time.at(i), time.at(i-2)+a.at(i-2)+b.at(i)+k);
    }
    DEBUG(time);

    std::cout << (n==1? i64{0} : std::max(time.at(n-2), time.at(n-1))) << '\n';
}
0