Submission #703141

#TimeUsernameProblemLanguageResultExecution timeMemory
703141piOOETeam Contest (JOI22_team)C++17
100 / 100
522 ms27144 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<array<int, 3>> a(n); set<pair<int, int>, greater<>> mx[3]; for (int i = 0; i < n; ++i) { cin >> a[i][0] >> a[i][1] >> a[i][2]; mx[0].emplace(a[i][0], i); mx[1].emplace(a[i][1], i); mx[2].emplace(a[i][2], i); } while (mx[0].size() > 2) { int i = mx[0].begin()->second; int j = mx[1].begin()->second; int k = mx[2].begin()->second; array<int, 3> b{a[i][0], a[j][1], a[k][2]}; bool yay = true; for (int x : {i, j, k}) { int cnt = 0; for (int p = 0; p < 3; ++p) { cnt += a[x][p] == b[p]; } if (cnt >= 2) { yay = false; mx[0].erase({a[x][0], x}); mx[1].erase({a[x][1], x}); mx[2].erase({a[x][2], x}); break; } } if (yay) { cout << b[0] + b[1] + b[2] << '\n'; return 0; } } cout << "-1\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...