이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
map<int, vector<pair<int, int>>> bckt;
int main() {
int n;
cin >> n;
vector<int> keys;
for (int i = 0; i < n; i++) {
int x, y, z;
cin >> x >> y >> z;
bckt[y].push_back({x, z});
keys.push_back(y);
}
sort(keys.begin(), keys.end());
keys.resize(unique(keys.begin(), keys.end()) - keys.begin());
int mx = -1;
for (int g : keys) {
for (auto pti : bckt[g]) {
set<tuple<int, int, int>> cand;
int mxz = -1;
for (int gg : keys) {
for (auto ptk : bckt[gg]) {
if (ptk.first < pti.first) {
if (gg < g)
mxz = max(mxz, ptk.second);
cand.insert({ptk.first, gg, ptk.second});
}
}
}
for (int gg : keys) {
if (gg <= g)
continue;
for (auto ptj : bckt[gg]) {
if (pti.first > ptj.first) {
if (mxz > pti.second && mxz > ptj.second) {
mx = max(mx, pti.first + gg + mxz);
}
}
}
for (auto ptj : bckt[gg]) {
if (cand.count({ptj.first, gg, ptj.second}))
mxz = max(mxz, ptj.second);
}
}
}
}
cout << mx << endl;
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... |