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 X[i] < X[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));
sy.erase(make_pair(-Z[i], i));
while (sy.empty() == false && sy.begin()->second == sz.begin()->second) {
sy.erase(sy.begin());
sz.erase(sz.begin());
}
if (sy.empty() == true) {
break;
}
answer = max(answer, X[i] - sy.begin()->first - sz.begin()->first);
}
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... |