Submission #1174985

#TimeUsernameProblemLanguageResultExecution timeMemory
1174985lopkusTeam Contest (JOI22_team)C++20
8 / 100
2093 ms13748 KiB
#include <bits/stdc++.h> using i64 = long long; using u64 = unsigned long long; using u32 = unsigned; using u128 = unsigned __int128; #define int long long void solve() { int N; std::cin >> N; std::vector<int> xx(N + 1), yy(N + 1), zz(N + 1); for(int i = 1; i <= N; i++) { std::cin >> xx[i] >> yy[i] >> zz[i]; } int tr = 0; std::vector<int> to_pr[10]; std::vector<int> w = {1, 2, 3}; do { for(int i = 0; i < 3; i++) { to_pr[tr].push_back(w[i]); } tr += 1; } while(next_permutation(w.begin(), w.end())); std::vector<int> x(N + 1), y(N + 1), z(N + 1); int ans = - 1; auto Do = [&] () { std::vector<std::array<int, 3>> r; for(int i = 1; i <= N; i++) { r.push_back({z[i], x[i], y[i]}); } sort(r.rbegin(), r.rend()); for(int i = 0; i < N; i++) { x[i + 1] = r[i][1]; y[i + 1] = r[i][2]; z[i + 1] = r[i][0]; } for(int a = N; a >= 1; a--) { for(int b = a - 1; b >= 1; b--) { if(x[a] <= x[b] || y[b] <= y[a]) { continue; } for(int c = 1; c < b; c++) { if(z[c] == std::max(z[a], z[b])) { break; } if(x[c] < x[a] && y[c] < y[b]) { ans = std::max(ans, x[a] + y[b] + z[c]); } } } } for(int a = 1; a <= N; a++) { for(int b = a + 1; b <= N; b++) { if(x[a] <= x[b] || y[b] <= y[a]) { continue; } for(int c = 1; c < a; c++) { if(z[c] == std::max(z[a], z[b])) { break; } if(x[c] < x[a] && y[c] < y[b] && z[c] > std::max(z[b], z[a])) { ans = std::max(ans, x[a] + y[b] + z[c]); } } } } }; for(int i = 0; i < 6; i++) { if(to_pr[i][0] == 1) { for(int i = 1; i <= N; i++) { x[i] = xx[i]; } } if(to_pr[i][0] == 2) { for(int i = 1; i <= N; i++) { x[i] = yy[i]; } } if(to_pr[i][0] == 3) { for(int i = 1; i <= N; i++) { x[i] = zz[i]; } } if(to_pr[i][1] == 1) { for(int i = 1; i <= N; i++) { y[i] = xx[i]; } } if(to_pr[i][1] == 2) { for(int i = 1; i <= N; i++) { y[i] = yy[i]; } } if(to_pr[i][1] == 3) { for(int i = 1; i <= N; i++) { y[i] = zz[i]; } } if(to_pr[i][2] == 1) { for(int i = 1; i <= N; i++) { z[i] = xx[i]; } } if(to_pr[i][2] == 2) { for(int i = 1; i <= N; i++) { z[i] = yy[i]; } } if(to_pr[i][2] == 3) { for(int i = 1; i <= N; i++) { z[i] = zz[i]; } } Do(); } std::cout << ans; } signed main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int t = 1; //std::cin >> t; while (t--) { solve(); } 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...