Submission #1212764

#TimeUsernameProblemLanguageResultExecution timeMemory
1212764dima2101Team Contest (JOI22_team)C++20
64 / 100
2085 ms13632 KiB
#include <bits/stdc++.h> #define int long long const int MAXN = 101; const int mod = 998244353; struct Node { int x, y, z; Node(int x, int y, int z) : x(x), y(y), z(z) {}; Node() = default; int get_max() { return std::max(x, std::max(y, z)); } }; signed main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int n; std::cin >> n; std::vector<Node> all(n); Node max = Node(0, 0, 0); for (int i = 0; i < n; i++) { std::cin >> all[i].x >> all[i].y >> all[i].z; max.x = std::max(max.x, all[i].x); max.y = std::max(max.y, all[i].y); max.z = std::max(max.z, all[i].z); } bool was = false; do { // std::cout << all.size() << std::endl; was = false; std::vector<Node> new_best; for (int i = 0; i < all.size(); i++) { int cnt = (max.x == all[i].x) + (max.y == all[i].y) + (max.z == all[i].z); if (cnt <= 1) { new_best.push_back(all[i]); } else { was = true; } } max = Node(0, 0, 0); all = new_best; for (int i = 0; i < all.size(); i++) { max.x = std::max(max.x, all[i].x); max.y = std::max(max.y, all[i].y); max.z = std::max(max.z, all[i].z); } } while (was); if (all.size() < 3) { std::cout << -1; return 0; } std::cout << max.x + max.y + max.z; }
#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...