Submission #553054

#TimeUsernameProblemLanguageResultExecution timeMemory
553054jesus_coconutTeam Contest (JOI22_team)C++17
100 / 100
86 ms9420 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<array<int, 3>> x(n); for (auto &[a, b, c] : x) { cin >> a >> b >> c; } auto y = x; auto z = x; sort(begin(x), end(x), [&](auto a, auto b) { return a[0] < b[0]; }); sort(begin(y), end(y), [&](auto a, auto b) { return a[1] < b[1]; }); sort(begin(z), end(z), [&](auto a, auto b) { return a[2] < b[2]; }); while (!x.empty() && !y.empty() && !z.empty()) { if (x.back()[1] >= y.back()[1] || x.back()[2] >= z.back()[2]) { x.pop_back(); continue; } if (y.back()[0] >= x.back()[0] || y.back()[2] >= z.back()[2]) { y.pop_back(); continue; } if (z.back()[0] >= x.back()[0] || z.back()[1] >= y.back()[1]) { z.pop_back(); continue; } break; } if (x.empty() || y.empty() || z.empty()) { cout << "-1\n"; } else { cout << x.back()[0] + y.back()[1] + z.back()[2] << '\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...