Submission #997181

#TimeUsernameProblemLanguageResultExecution timeMemory
997181vladiliusTeam Contest (JOI22_team)C++17
100 / 100
591 ms76628 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; #define pb push_back #define ff first #define ss second #define ins insert int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; vector<int> x(n + 1), y(n + 1), z(n + 1); map<pii, vector<int>> mp1, mp2, mp3; vector<bool> ban(n + 1); int m = n; for (int i = 1; i <= n; i++){ cin>>x[i]>>y[i]>>z[i]; mp1[{x[i], y[i]}].pb(i); mp2[{x[i], z[i]}].pb(i); mp3[{y[i], z[i]}].pb(i); } multiset<int> sx, sy, sz; for (int i = 1; i <= n; i++){ sx.ins(x[i]); sy.ins(y[i]); sz.ins(z[i]); } auto erase = [&](int i){ ban[i] = 1; m--; sx.erase(sx.find(x[i])); sy.erase(sy.find(y[i])); sz.erase(sz.find(z[i])); }; while (m >= 3){ int f1 = *prev(sx.end()), f2 = *prev(sy.end()), f3 = *prev(sz.end()); bool ind = 1; for (int j: mp1[{f1, f2}]){ if (ban[j]) continue; ind = 0; erase(j); } for (int j: mp2[{f1, f3}]){ if (ban[j]) continue; ind = 0; erase(j); } for (int j: mp3[{f2, f3}]){ if (ban[j]) continue; ind = 0; erase(j); } if (ind){ cout<<f1 + f2 + f3<<"\n"; return 0; } } cout<<-1<<"\n"; }
#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...