Submission #927939

#TimeUsernameProblemLanguageResultExecution timeMemory
927939OAleksaTeam Contest (JOI22_team)C++14
64 / 100
2017 ms17496 KiB
#include <bits/stdc++.h> using namespace std; #define f first #define s second const int N = 2e5 + 69; int n, a[N], b[N], c[N]; signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int tt = 1; //cin >> tt; while (tt--) { cin >> n; set<int> st; for (int i = 1;i <= n;i++) { cin >> a[i] >> b[i] >> c[i]; st.insert(i); } while (1) { int x = 0, y = 0, z = 0; for (auto u : st) { x = max(x, a[u]); y = max(y, b[u]); z = max(z, c[u]); } set<int> del; for (auto u : st) { if (a[u] == x && b[u] == y) del.insert(u); else if (a[u] == x && c[u] == z) del.insert(u); else if (b[u] == y && c[u] == z) del.insert(u); else if (a[u] == x && b[u] == y && c[u] == z) del.insert(u); } if (del.empty()) break; for (auto u : del) st.erase(u); } int ans = -1; if (st.size() > 2) { int x = 0, y = 0, z = 0; for (auto u : st) { x = max(x, a[u]); y = max(y, b[u]); z = max(z, c[u]); } ans = x + y + 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...