Submission #1059565

#TimeUsernameProblemLanguageResultExecution timeMemory
1059565vjudge1Team Contest (JOI22_team)C++17
0 / 100
1 ms604 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; // #define int ll const int N = 2e5 + 2, MOD = 998244353; int a[N],b[N],c[N],n; set<pair<int,int>> x,y,z; void del(int i) { x.erase({a[i],i}); y.erase({b[i],i}); z.erase({c[i],i}); } void test() { cin >> n; for(int i = 1;i <= n;i++) { cin >> a[i] >> b[i] >> c[i]; x.insert({a[i],i}); y.insert({b[i],i}); z.insert({c[i],i}); } while(true) { if(x.empty()) { cout << -1; return; } auto [v,i] = (*x.rbegin()); auto [v1,j] = (*y.rbegin()); auto [v2,k] = (*z.rbegin()); if(i == j && j == k) { del(i); continue; } if(i == j || i == k) { del(i); } else if(j == k) { del(j); } else { cout << v + v1 + v2; return; } } } signed main() { ios_base::sync_with_stdio(false);cin.tie(0); int t = 1; // cin >> t; while(t--) { test(); } }
#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...