This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
#define size(x) (int)x.size()
template<class S, class T>
bool chmin(S &a, const T &b) {
return a > b && (a = b) == b;
}
template<class S, class T>
bool chmax(S &a, const T &b) {
return a < b && (a = b) == b;
}
const int inf = 1e9 + 7;
const int INF = 1e18 + 7;
const int mod = 998244353;
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n;
cin >> n;
vector<pair<int, int>> x(n), y(n), z(n);
int X[n], Y[n], Z[n];
for (int i = 0; i < n; ++i) {
cin >> X[i] >> Y[i] >> Z[i];
x[i] = {X[i], i}, y[i] = {Y[i], i}, z[i] = {Z[i], i};
}
sort(all(x), greater<pair<int, int>>());
sort(all(y), greater<pair<int, int>>());
sort(all(z), greater<pair<int, int>>());
int res = -1;
for (int i = 0; i < min(500ll, n); ++i) {
for (int j = 0; j < min(500ll, n); ++j) {
if (x[i].second == y[j].second || X[x[i].second] <= X[y[j].second] || Y[x[i].second] >= Y[y[j].second]) {
continue;
}
for (int k = 0; k < min(500ll, n); ++k) {
if (x[i].second == z[k].second || y[j].second == z[k].second || X[x[i].second] <= X[z[k].second] || Y[z[k].second] >= Y[y[j].second] || Z[z[k].second] <= Z[x[i].second] || Z[z[k].second] <= Z[y[j].second]) {
continue;
}
chmax(res, x[i].first + y[j].first + z[k].first);
}
}
}
cout << res;
}
# | 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... |