Submission #597619

#TimeUsernameProblemLanguageResultExecution timeMemory
597619MilosMilutinovicTeam Contest (JOI22_team)C++14
100 / 100
387 ms33604 KiB
/** * author: wxhtzdy * created: 16.07.2022 13:52:34 **/ #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<vector<int>> a(n, vector<int>(3)); for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { cin >> a[i][j]; } } vector<set<pair<int, int>>> st(3); for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { st[j].emplace(a[i][j], i); } } vector<bool> is(n); while (!st[0].empty() && !st[1].empty() && !st[2].empty()) { bool ok = true; for (int i = 0; i < 3; i++) { int idx = prev(st[i].end())->second; for (int j = 0; j < 3; j++) { if (i == j) { continue; } if (a[idx][j] >= a[prev(st[j].end())->second][j]) { ok = false; is[idx] = true; } } } if (ok) { int ans = 0; for (int i = 0; i < 3; i++) { ans += prev(st[i].end())->first; } cout << ans << '\n'; return 0; } for (int i = 0; i < 3; i++) { while (!st[i].empty() && is[prev(st[i].end())->second]) { st[i].erase(prev(st[i].end())); } } } 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...