제출 #1124106

#제출 시각아이디문제언어결과실행 시간메모리
1124106hmm789Team Contest (JOI22_team)C++20
100 / 100
146 ms13468 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define INF 1000000000 int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; int a[n], b[n], c[n], bad[n]; memset(bad, 0, sizeof(bad)); priority_queue<pair<int, int>> A, B, C; for(int i = 0; i < n; i++) { cin >> a[i] >> b[i] >> c[i]; A.push({a[i], i}); B.push({b[i], i}); C.push({c[i], i}); } for(int i = 0; i < n; i++) { int x = A.top().second; int y = B.top().second; int z = C.top().second; if(b[x] == b[y] || c[x] == c[z]) bad[x] = 1; if(a[y] == a[x] || c[y] == c[z]) bad[y] = 1; if(a[z] == a[x] || b[z] == b[y]) bad[z] = 1; if(!bad[x] && !bad[y] && !bad[z]) { cout << a[x] + b[y] + c[z] << '\n'; return 0; } while(A.size() && bad[A.top().second]) A.pop(); while(B.size() && bad[B.top().second]) B.pop(); while(C.size() && bad[C.top().second]) C.pop(); } 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...