Submission #945143

#TimeUsernameProblemLanguageResultExecution timeMemory
945143alextodoranTeam Contest (JOI22_team)C++17
100 / 100
307 ms20816 KiB
/** _ _ __ _ _ _ _ _ _ |a ||t ||o d | |o | | __ _| | _ | __| _ | | __ |/_ | __ /__\ / _\| **/ #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N_MAX = 150000; int N; int X[N_MAX + 2], Y[N_MAX + 2], Z[N_MAX + 2]; int order[N_MAX + 2]; set <pair <int, int>> sy, sz; int main () { ios_base::sync_with_stdio(false); cin.tie(0); cin >> N; for (int i = 1; i <= N; i++) { cin >> X[i] >> Y[i] >> Z[i]; } iota(order + 1, order + N + 1, 1); sort(order + 1, order + N + 1, [&] (const int &i, const int &j) { return X[i] < X[j]; }); for (int i = 1; i <= N; i++) { sy.insert(make_pair(-Y[i], i)); sz.insert(make_pair(-Z[i], i)); } int answer = -1; for (int a = N, b = N; a >= 1; a--) { int i = order[a]; while (b >= 1 && X[i] == X[order[b]]) { int i = order[b--]; sy.erase(make_pair(-Y[i], i)); sz.erase(make_pair(-Z[i], i)); } while (sy.empty() == false && Z[sy.begin()->second] == Z[sz.begin()->second]) { int j = sy.begin()->second; sy.erase(make_pair(-Y[j], j)); sz.erase(make_pair(-Z[j], j)); } while (sz.empty() == false && Y[sz.begin()->second] == Y[sy.begin()->second]) { int j = sz.begin()->second; sz.erase(make_pair(-Z[j], j)); sy.erase(make_pair(-Y[j], j)); } if (sy.empty() == true) { break; } int j = sy.begin()->second; int k = sz.begin()->second; if (X[i] > max(X[j], X[k]) && Y[j] > max(Y[i], Y[k]) && Z[k] > max(Z[i], Z[j])) { answer = max(answer, X[i] + Y[j] + Z[k]); } } cout << answer << "\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...