Submission #48170121


Source Code Expand

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

namespace {
    using ModInt [[maybe_unused]] = atcoder::modint998244353;
    using Num [[maybe_unused]] = long long int;
    using Vec [[maybe_unused]] = std::vector<Num>;
    using Set [[maybe_unused]] = std::set<Num>;
    using Mset [[maybe_unused]] = std::multiset<Num>;
    using Edges [[maybe_unused]] = std::vector<std::vector<Num>>;

    template<typename T>
    using Q [[maybe_unused]] = std::queue<T>;

    constexpr Num MinCost = -1000000000000000LL;

    Num apply(Num a, Num b) {
        return std::max(a, b);
    }

    Num unit(void) {
        return MinCost;
    }
}

void solve(std::istream& is, std::ostream& os) {
    Num n, m, l;
    is >> n >> m >> l;

    std::vector<Num> aset(n);
    for(auto&& a : aset) {
        is >> a;
    }

    std::vector<Num> bset(m);
    atcoder::segtree<Num, apply, unit> tree(m);
    for(Num i{0}; i<m; ++i) {
        Num b;
        is >> b;
        bset.at(i) = b;
        tree.set(i, b);
    }

    Edges edges(n);
    for(Num i{0}; i<l; ++i) {
        Num c, d;
        is >> c >> d;
        --c;
        --d;
        edges[c].push_back(d);
    }

    Num answer {0};
    for(Num i{0}; i<n; ++i) {
        for(const auto& b : edges[i]) {
            tree.set(b, MinCost);
        }

        const auto s = aset.at(i) + tree.prod(0, m);
        answer = std::max(answer, s);

        for(const auto& b : edges[i]) {
            tree.set(b, bset.at(b));
        }
    }

    os << answer << "\n";
}

int main(void) {
    solve(std::cin, std::cout);
    return 0;
}

Submission Info

Submission Time
Task E - Set Meal
User zettsut
Language C++ 20 (gcc 12.2)
Score 450
Code Size 1674 Byte
Status AC
Exec Time 91 ms
Memory 12320 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 450 / 450
Status
AC × 3
AC × 23
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 03_max_00.txt, 03_max_01.txt, 03_max_02.txt, 03_max_03.txt, 03_max_04.txt, 04_hack_00.txt, 04_hack_01.txt, 04_hack_02.txt, 04_hack_03.txt, 04_hack_04.txt, 04_hack_05.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3464 KiB
00_sample_01.txt AC 1 ms 3548 KiB
00_sample_02.txt AC 1 ms 3508 KiB
01_small_00.txt AC 2 ms 3584 KiB
01_small_01.txt AC 2 ms 3572 KiB
01_small_02.txt AC 8 ms 3844 KiB
01_small_03.txt AC 7 ms 3732 KiB
02_random_00.txt AC 30 ms 4832 KiB
02_random_01.txt AC 24 ms 6364 KiB
02_random_02.txt AC 70 ms 9516 KiB
02_random_03.txt AC 63 ms 9348 KiB
02_random_04.txt AC 40 ms 7436 KiB
03_max_00.txt AC 72 ms 10328 KiB
03_max_01.txt AC 91 ms 10244 KiB
03_max_02.txt AC 73 ms 10324 KiB
03_max_03.txt AC 90 ms 10296 KiB
03_max_04.txt AC 73 ms 10240 KiB
04_hack_00.txt AC 81 ms 10764 KiB
04_hack_01.txt AC 77 ms 9988 KiB
04_hack_02.txt AC 75 ms 10240 KiB
04_hack_03.txt AC 78 ms 10596 KiB
04_hack_04.txt AC 84 ms 12320 KiB
04_hack_05.txt AC 26 ms 4456 KiB