結果

問題 No.1104 オンライン点呼
ユーザー ngtkanangtkana
提出日時 2020-05-16 08:58:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 1,343 bytes
コンパイル時間 2,508 ms
コンパイル使用メモリ 204,588 KB
実行使用メモリ 5,600 KB
最終ジャッジ日時 2023-10-22 06:49:51
合計ジャッジ時間 3,462 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 27 ms
5,600 KB
testcase_02 AC 26 ms
5,600 KB
testcase_03 AC 20 ms
5,600 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 12 ms
4,544 KB
testcase_08 AC 6 ms
4,348 KB
testcase_09 AC 15 ms
5,600 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 9 ms
4,348 KB
testcase_12 AC 13 ms
4,544 KB
testcase_13 AC 10 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 17 ms
4,808 KB
testcase_16 AC 20 ms
5,336 KB
testcase_17 AC 13 ms
4,348 KB
testcase_18 AC 16 ms
4,808 KB
testcase_19 AC 22 ms
5,072 KB
testcase_20 AC 23 ms
5,336 KB
testcase_21 AC 24 ms
5,336 KB
testcase_22 AC 20 ms
5,072 KB
testcase_23 AC 16 ms
4,544 KB
testcase_24 AC 8 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

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