#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
using namespace std;
using namespace chrono;
const int N = 150000;
int x[N], y[N], z[N];
vector<int> X[301], Y[301], Z[301];
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n; cin >> n;
set<tuple<int,int,int>> s;
for (int i = 0; i < n; i++) {
int x,y,z; cin >> x >> y >> z;
s.emplace(x, y, z);
}
if (n <= 300) {
int ans = -1;
for (auto [xi, yi, zi]: s) {
for (auto [xj, yj, zj]: s) {
for (auto [xk, yk, zk]: s) {
if (xi > max(xj, xk) &&
yj > max(yi, yk) &&
zk > max(zi, zj)) {
ans = max(ans, xi + yj + zk);
}
}
}
}
cout << ans;
exit(0);
}
int ans = -1;
for (int xi = 1; xi <= 300; xi++) {
for (int yj = 1; yj <= 300; yj++) {
for (int zk = 1; zk <= 300; zk++) {
int cnt = 0;
for (int i : X[xi]) {
if (y[i] < yj && z[i] < zk) {
cnt++;
break;
}
}
for (int j : Y[yj]) {
if (x[j] < xi && z[j] < zk) {
cnt++;
break;
}
}
for (int k : Z[zk]) {
if (x[k] < xi && y[k] < yj) {
cnt++;
break;
}
}
if (cnt == 3) ans = max(ans, xi + yj + zk);
}
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |