結果

問題 No.704 ゴミ拾い Medium
ユーザー lorent_kyoprolorent_kyopro
提出日時 2021-04-07 00:29:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 922 bytes
コンパイル時間 2,341 ms
コンパイル使用メモリ 205,852 KB
実行使用メモリ 16,040 KB
最終ジャッジ日時 2023-09-02 18:42:52
合計ジャッジ時間 11,760 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 1 ms
4,368 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 5 ms
8,288 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,368 KB
testcase_06 WA -
testcase_07 RE -
testcase_08 AC 2 ms
4,372 KB
testcase_09 AC 1 ms
4,368 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,368 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 RE -
testcase_15 AC 5 ms
8,788 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 6 ms
8,844 KB
testcase_21 AC 6 ms
8,796 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/segtree>

__attribute__((constructor))
void fast_io() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
}
 

using S = std::pair<long long, long long>;
S op(S a, S b) {
    return {std::min(a.first, b.first), std::min(a.second, b.second)};
}
S e() { return {LLONG_MAX >> 1, LLONG_MAX >> 1}; };

int main() {
    size_t n;
    std::cin >> n;
    std::vector<long long> a(n), x(n), y(n);
    for (auto& ai : a) std::cin >> ai;
    for (auto& xi : x) std::cin >> xi;
    for (auto& yi : y) std::cin >> yi;

    long long xmax = *std::max_element(x.begin(), x.end());
    atcoder::segtree<S, op, e> seg(xmax + 1);
    long long dp = 0;
    for (size_t i = 0; i < n; ++i) {
        seg.set(x[i], {dp - x[i] + y[i], dp + x[i] + y[i]});
        dp = std::min(seg.prod(0, a[i]).first + a[i], seg.prod(a[i], xmax).second - a[i]);
    }
    std::cout << dp << '\n';
}
0