This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
_ _ __ _ _ _ _ _ _
|a ||t ||o d | |o |
| __ _| | _ | __| _ |
| __ |/_ | __ /__\ / _\|
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N_MAX = 150000;
int N;
int X[N_MAX + 2], Y[N_MAX + 2], Z[N_MAX + 2];
int order[N_MAX + 2];
set <pair <int, int>> sy, sz;
int main () {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> N;
for (int i = 1; i <= N; i++) {
cin >> X[i] >> Y[i] >> Z[i];
}
iota(order + 1, order + N + 1, 1);
sort(order + 1, order + N + 1, [&] (const int &i, const int &j) {
return make_tuple(X[i], Y[i], Z[i]) < make_tuple(X[j], Y[j], Z[j]);
});
for (int i = 1; i <= N; i++) {
sy.insert(make_pair(-Y[i], i));
sz.insert(make_pair(-Z[i], i));
}
int answer = -1;
for (int _ = N; _ >= 1; _--) {
int i = order[_];
sy.erase(make_pair(-Y[i], i));
sz.erase(make_pair(-Z[i], i));
while (sy.empty() == false && Z[sy.begin()->second] == Z[sz.begin()->second]) {
int j = sy.begin()->second;
sy.erase(make_pair(-Y[j], j));
sz.erase(make_pair(-Z[j], j));
}
while (sz.empty() == false && Y[sz.begin()->second] == Y[sy.begin()->second]) {
int j = sz.begin()->second;
sz.erase(make_pair(-Z[j], j));
sy.erase(make_pair(-Y[j], j));
}
if (sy.empty() == true) {
break;
}
int j = sy.begin()->second;
int k = sz.begin()->second;
if (X[i] > max(X[j], X[k]) && Y[j] > max(Y[i], Y[k]) && Z[k] > max(Z[i], Z[j])) {
answer = max(answer, X[i] + Y[j] + Z[k]);
}
}
cout << answer << "\n";
return 0;
}
# | 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... |