Submission #567827

#TimeUsernameProblemLanguageResultExecution timeMemory
567827maomao90Team Contest (JOI22_team)C++17
0 / 100
30 ms4524 KiB
#include <bits/stdc++.h> using namespace std; #define REP(i, j, k) for (int i = j; i < k; i++) #define RREP(i, j, k) for (int i = j; i >= k; i--) template <class T> bool mnto(T &a, const T b) {return a > b ? a = b, 1 : 0;} template <class T> bool mxto(T &a, const T b) {return a < b ? a = b, 1 : 0;} typedef long long ll; #define FI first #define SE second typedef pair<int, int> ii; typedef pair<ll, ll> pll; typedef tuple<int, int, int> iii; #define ALL(x) x.begin(), x.end() #define SZ(x) (int) x.size() #define pb push_back typedef vector<int> vi; typedef vector<ii> vii; typedef vector<ll> vll; #ifndef DEBUG #define cerr if(0) cerr #endif const int MAXN = 150005; const int INF = 1000000005; const ll LINF = 1000000000000000005; int n; iii xyz[MAXN]; set<ii> st[2]; ii lft, rht; int ans; int main() { #ifndef DEBUG ios::sync_with_stdio(0), cin.tie(0); #endif cin >> n; REP (i, 0, n) { int x, y, z; cin >> x >> y >> z; xyz[i] = {x, y, z}; } sort(xyz, xyz + n, [&] (iii l, iii r) { return get<1>(l) < get<1>(r); }); ans = -1; int ptr = 0; int mx[2] = {-1, -1}, mz[2] = {-1, -1}; REP (i, 0, n) { while (ptr < i && get<1>(xyz[ptr]) < get<1>(xyz[i])) { auto [x, y, z] = xyz[ptr++]; { auto [ptr, yes] = st[0].insert({x, z}); if (!yes) { continue; } while (next(ptr) != st[0].end() && next(ptr) -> SE < z) { bool bz = mxto(mz[0], z); bool bx = mxto(mx[0], next(ptr) -> FI); if (bx || bz) { assert(mz[0] == z && mx[0] == next(ptr) -> FI); } st[0].erase(next(ptr)); } if (ptr != st[0].begin() && prev(ptr) -> SE > z) { bool bz = mxto(mz[0], prev(ptr) -> SE); bool bx = mxto(mx[0], x); if (bx || bz) { assert(mz[0] == prev(ptr) -> SE && mx[0] == x); } st[0].erase(ptr); } } { auto [ptr, yes] = st[1].insert({x, z}); if (!yes) { continue; } while (ptr != st[1].begin() && prev(ptr) -> SE > z) { bool bz = mxto(mz[1], prev(ptr) -> SE); bool bx = mxto(mx[1], x); if (bx || bz) { assert(mz[1] == prev(ptr) -> SE && mx[1] == x); } st[1].erase(prev(ptr)); } if (next(ptr) != st[1].end() && next(ptr) -> SE < z) { bool bz = mxto(mz[1], z); bool bx = mxto(mx[1], next(ptr) -> FI); if (bx || bz) { assert(mz[1] == z && mx[1] == next(ptr) -> FI); } st[1].erase(ptr); } } } REP (z, 0, 2) { int my = -INF; auto [cx, cy, cz] = xyz[i]; if (mx[z] == -1) continue; if (cx < mx[z] && cz < mz[z]) { my = cy; } if (my != -INF) { mxto(ans, mx[z] + my + mz[z]); } } } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...