Submission #938599

# Submission time Handle Problem Language Result Execution time Memory
938599 2024-03-05T10:56:52 Z Pannda Team Contest (JOI22_team) C++17
9 / 100
65 ms 3628 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    map<int, vector<array<int, 2>>> mp;
    for (int i = 0; i < n; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        mp[z].push_back({x, y});
    }

    set<array<int, 2>> xy;
    set<array<int, 2>> yx;
    set<array<int, 2>> xy_defer;
    set<array<int, 2>> yx_defer;
    static const int INF = 1e9;

    auto add = [&](int x, int y) -> void {
        bool popped = false;
        while (!xy_defer.empty()) {
            auto it = xy_defer.lower_bound(array<int, 2>{x, -INF});
            if (it == xy_defer.begin()) break;
            it--;
            auto [xx, yy] = *it;
            if (yy <= y) break;
            xy_defer.erase(it);
            yx_defer.erase({yy, xx});
            xy.insert({xx, yy});
            yx.insert({yy, xx});
            popped = true;
        }
        while (!yx_defer.empty()) {
            auto it = yx_defer.lower_bound(array<int, 2>{y, -INF});
            if (it == yx_defer.begin()) break;
            it--;
            auto [yy, xx] = *it;
            if (xx <= x) break;
            yx_defer.erase(it);
            xy_defer.erase({xx, yy});
            xy.insert({xx, yy});
            yx.insert({yy, xx});
            popped = true;
        }
        if (popped) {
            xy.insert({x, y});
            yx.insert({y, x});
        } else {
            xy_defer.insert({x, y});
            yx_defer.insert({y, x});
        }
    };

    auto query = [&](int x, int y) -> int {
        if (xy.empty()) return -INF;
        int xx = (*xy.rbegin())[0];
        int yy = (*yx.rbegin())[0];
        if (xx <= x || yy <= y) return -INF;
        return xx + yy;
    };

    int res = -1;
    for (auto [z, xy] : mp) {
        for (auto [x, y] : xy) {
            res = max(res, z + query(x, y));
        }
        for (auto [x, y] : xy) {
            add(x, y);
        }
    }
    cout << res << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 456 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Incorrect 1 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 456 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Incorrect 1 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 464 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 456 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 47 ms 2724 KB Output is correct
12 Correct 24 ms 2212 KB Output is correct
13 Correct 22 ms 2800 KB Output is correct
14 Correct 37 ms 3280 KB Output is correct
15 Correct 29 ms 3628 KB Output is correct
16 Correct 22 ms 3476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 464 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 456 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 47 ms 2724 KB Output is correct
12 Correct 24 ms 2212 KB Output is correct
13 Correct 22 ms 2800 KB Output is correct
14 Correct 37 ms 3280 KB Output is correct
15 Correct 29 ms 3628 KB Output is correct
16 Correct 22 ms 3476 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 65 ms 2560 KB Output is correct
23 Correct 54 ms 2764 KB Output is correct
24 Incorrect 40 ms 2504 KB Output isn't correct
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 464 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 456 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 47 ms 2724 KB Output is correct
12 Correct 24 ms 2212 KB Output is correct
13 Correct 22 ms 2800 KB Output is correct
14 Correct 37 ms 3280 KB Output is correct
15 Correct 29 ms 3628 KB Output is correct
16 Correct 22 ms 3476 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 65 ms 2560 KB Output is correct
23 Correct 54 ms 2764 KB Output is correct
24 Incorrect 40 ms 2504 KB Output isn't correct
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 464 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 456 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 47 ms 2724 KB Output is correct
12 Correct 24 ms 2212 KB Output is correct
13 Correct 22 ms 2800 KB Output is correct
14 Correct 37 ms 3280 KB Output is correct
15 Correct 29 ms 3628 KB Output is correct
16 Correct 22 ms 3476 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 65 ms 2560 KB Output is correct
23 Correct 54 ms 2764 KB Output is correct
24 Incorrect 40 ms 2504 KB Output isn't correct
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 456 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Incorrect 1 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -