Submission #945342

#TimeUsernameProblemLanguageResultExecution timeMemory
945342socpiteTeam Contest (JOI22_team)C++14
100 / 100
379 ms27468 KiB
#include<bits/stdc++.h> using namespace std; const int maxn = 150005; int A[maxn], B[maxn], C[maxn]; int n; set<pair<int, int>> sa, sb, sc; bool check(int id){ return int(A[id] == sa.rbegin()->first) + int(B[id] == sb.rbegin()->first) + int(C[id] == sc.rbegin()->first) < 2; } void rmv(int id){ sa.erase({A[id], id}); sb.erase({B[id], id}); sc.erase({C[id], id}); } int main(){ ios::sync_with_stdio(false); cin.tie(0); cin >> n; for(int i = 1; i <= n; i++){ cin >> A[i] >> B[i] >> C[i]; sa.insert({A[i], i}); sb.insert({B[i], i}); sc.insert({C[i], i}); } while(!sa.empty()){ if(!check(sa.rbegin()->second)){ rmv(sa.rbegin()->second); continue; } if(!check(sb.rbegin()->second)){ rmv(sb.rbegin()->second); continue; } if(!check(sc.rbegin()->second)){ rmv(sc.rbegin()->second); continue; } break; } if(sa.empty()){ cout << "-1"; return 0; } cout << sa.rbegin()->first + sb.rbegin()->first + sc.rbegin()->first; }
#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...