Submission #1145835

#TimeUsernameProblemLanguageResultExecution timeMemory
1145835antonnTeam Contest (JOI22_team)C++20
100 / 100
271 ms23308 KiB
#include <bits/stdc++.h> #define F first #define S second using namespace std; using ll = long long; using pi = pair<int, int>; using vi = vector<int>; template<class T> bool ckmin(T& a, T b) { return b < a ? a = b, true : false; } template<class T> bool ckmax(T& a, T b) { return a < b ? a = b, true : false; } int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<array<int, 3>> a(n + 1); set<pair<int, int>> s1, s2, s3; for (int i = 1; i <= n; ++i) { cin >> a[i][0] >> a[i][1] >> a[i][2]; s1.insert({a[i][0], i}); s2.insert({a[i][1], i}); s3.insert({a[i][2], i}); } auto scoate = [&](int x) -> void { s1.erase({a[x][0], x}); s2.erase({a[x][1], x}); s3.erase({a[x][2], x}); }; while (!s1.empty()) { int x = (*s1.rbegin()).S; int y = (*s2.rbegin()).S; int z = (*s3.rbegin()).S; if (a[x][1] >= a[y][1]) { scoate(x); } else if (a[x][2] >= a[z][2]) { scoate(x); } else if (a[y][0] >= a[x][0]) { scoate(y); } else if (a[y][2] >= a[z][2]) { scoate(y); } else if (a[z][0] >= a[x][0]) { scoate(z); } else if (a[z][1] >= a[y][1]) { scoate(z); } else { cout << a[x][0] + a[y][1] + a[z][2] << "\n"; return 0; } } 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...