Skip to the content.

:heavy_check_mark: test/line_add_get_min2.test.cpp

Depends on

Code

#define PROBLEM "https://judge.yosupo.jp/problem/line_add_get_min"

#include <sys/types.h>  // for uint

#include <algorithm>                        // for sort, unique
#include <data_structure/li_chao_tree.hpp>  // for LiChaoTree
#include <fastio/base.hpp>                  // for cin, FASTIO, cout
#include <fastio/char/write.hpp>            // for operator<<
#include <fastio/signed/read.hpp>           // for operator>>
#include <fastio/signed/write.hpp>          // for operator<<
#include <fastio/unsigned/read.hpp>         // for operator>>
#include <math/inf.hpp>                     // for INF
#include <templates/macro/abbrev/eb.hpp>    // for eb
#include <templates/macro/abbrev/endl.hpp>  // for endl
#include <templates/macro/abbrev/ext.hpp>   // for ext
#include <templates/macro/abbrev/ll.hpp>    // for ll
#include <templates/rep.hpp>                // for rep
#include <templates/template.hpp>
#include <vector>  // for vector

int main() {
    int n, q;
    cin >> n >> q;
    vector<ll> x;
    struct node {
        ll a, b;
    };
    vector<node> a(n);
    rep(i, n) {
        cin >> a[i].a >> a[i].b;
    }
    vector<node> t(q);
    rep(i, q) {
        uint T;
        cin >> T;
        if (T == 0) {
            cin >> t[i].a >> t[i].b;
        } else {
            cin >> t[i].a;
            t[i].b = Infinite{};
            x.eb(t[i].a);
        }
    }
    LiChaoTree<ll, []() -> ll { return Infinite{}; }> tree(x);
    if (x.empty()) {
        ext;
    }
    rep(i, n) {
        tree.add(a[i].a, a[i].b);
    }
    rep(i, q) {
        if (t[i].b == (ll)(Infinite{})) {
            cout << tree(t[i].a) << endl;
        } else {
            tree.add(t[i].a, t[i].b);
        }
    }
}
#line 1 "test/line_add_get_min2.test.cpp"
#define PROBLEM "https://judge.yosupo.jp/problem/line_add_get_min"

#include <sys/types.h>  // for uint

#include <algorithm>                        // for sort, unique
#include <data_structure/li_chao_tree.hpp>  // for LiChaoTree
#include <fastio/base.hpp>                  // for cin, FASTIO, cout
#include <fastio/char/write.hpp>            // for operator<<
#include <fastio/signed/read.hpp>           // for operator>>
#include <fastio/signed/write.hpp>          // for operator<<
#include <fastio/unsigned/read.hpp>         // for operator>>
#include <math/inf.hpp>                     // for INF
#include <templates/macro/abbrev/eb.hpp>    // for eb
#include <templates/macro/abbrev/endl.hpp>  // for endl
#include <templates/macro/abbrev/ext.hpp>   // for ext
#include <templates/macro/abbrev/ll.hpp>    // for ll
#include <templates/rep.hpp>                // for rep
#include <templates/template.hpp>
#include <vector>  // for vector

int main() {
    int n, q;
    cin >> n >> q;
    vector<ll> x;
    struct node {
        ll a, b;
    };
    vector<node> a(n);
    rep(i, n) {
        cin >> a[i].a >> a[i].b;
    }
    vector<node> t(q);
    rep(i, q) {
        uint T;
        cin >> T;
        if (T == 0) {
            cin >> t[i].a >> t[i].b;
        } else {
            cin >> t[i].a;
            t[i].b = Infinite{};
            x.eb(t[i].a);
        }
    }
    LiChaoTree<ll, []() -> ll { return Infinite{}; }> tree(x);
    if (x.empty()) {
        ext;
    }
    rep(i, n) {
        tree.add(a[i].a, a[i].b);
    }
    rep(i, q) {
        if (t[i].b == (ll)(Infinite{})) {
            cout << tree(t[i].a) << endl;
        } else {
            tree.add(t[i].a, t[i].b);
        }
    }
}

Test cases

Env Name Status Elapsed Memory
g++ example_00 :heavy_check_mark: AC 6 ms 4 MB
g++ half_00 :heavy_check_mark: AC 43 ms 20 MB
g++ hand_max_00 :heavy_check_mark: AC 163 ms 31 MB
g++ max_random_00 :heavy_check_mark: AC 66 ms 29 MB
g++ max_random_01 :heavy_check_mark: AC 67 ms 29 MB
g++ max_random_02 :heavy_check_mark: AC 66 ms 29 MB
g++ no_output_00 :heavy_check_mark: AC 23 ms 24 MB
g++ parabola_random_00 :heavy_check_mark: AC 154 ms 28 MB
g++ parabola_random_01 :heavy_check_mark: AC 154 ms 28 MB
g++ parabola_random_02 :heavy_check_mark: AC 154 ms 28 MB
g++ random_00 :heavy_check_mark: AC 50 ms 23 MB
g++ random_01 :heavy_check_mark: AC 53 ms 24 MB
g++ random_02 :heavy_check_mark: AC 36 ms 16 MB
g++ small_00 :heavy_check_mark: AC 5 ms 4 MB
g++ small_01 :heavy_check_mark: AC 5 ms 4 MB
Back to top page