#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |