Submission #567767

#TimeUsernameProblemLanguageResultExecution timeMemory
567767maomao90Team Contest (JOI22_team)C++17
0 / 100
33 ms2004 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; 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; REP (i, 0, n) { auto [x, y, z] = xyz[i]; if (st.size() >= 2) { int mx = prev(st.end()) -> FI, mz = st.begin() -> SE; int my = -INF; RREP (j, n - 1, i) { auto [cx, cy, cz] = xyz[j]; if (cy == get<1>(xyz[i - 1])) break; if (cx < mx && cz < mz) { my = cy; break; } } if (my != -INF) { mxto(ans, mx + my + mz); } } auto [it, yes] = st.insert(ii{x, z}); if (!yes) { continue; } if (next(it) != st.end() && next(it) -> SE >= z) { it = st.erase(it); assert(next(it) == st.end() || it -> FI != next(it) -> FI); assert(it == st.begin() || it -> FI != prev(it) -> FI); assert(next(it) == st.end() || it -> SE > next(it) -> SE); assert(it == st.begin() || it -> SE < prev(it) -> SE); continue; } while (it != st.begin() && prev(it) -> SE <= z) { st.erase(prev(it)); } assert(next(it) == st.end() || it -> FI != next(it) -> FI); assert(it == st.begin() || it -> FI != prev(it) -> FI); assert(next(it) == st.end() || it -> SE > next(it) -> SE); assert(it == st.begin() || it -> SE < prev(it) -> SE); } 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...