#include <bits/stdc++.h>
using namespace std;
map<int, vector<pair<int, int>>> bckt;
int main() {
int n;
cin >> n;
vector<int> keys;
vector<tuple<int, int, int>> raw;
for (int i = 0; i < n; i++) {
int x, y, z;
cin >> x >> y >> z;
raw.push_back({x, y, z});
}
sort(raw.begin(), raw.end());
raw.resize(unique(raw.begin(), raw.end()) - raw.begin());
for (auto p : raw) {
int x, y, z;
tie(x, y, z) = p;
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]) {
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);
}
}
}
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 (ptj.first < pti.first)
mxz = max(mxz, ptj.second);
}
}
}
}
cout << mx << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
300 KB |
Output is correct |
9 |
Correct |
0 ms |
296 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
5 ms |
352 KB |
Output is correct |
15 |
Correct |
2 ms |
212 KB |
Output is correct |
16 |
Correct |
2 ms |
212 KB |
Output is correct |
17 |
Correct |
3 ms |
308 KB |
Output is correct |
18 |
Correct |
2 ms |
212 KB |
Output is correct |
19 |
Correct |
2 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
300 KB |
Output is correct |
22 |
Correct |
3 ms |
308 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
2 ms |
292 KB |
Output is correct |
25 |
Correct |
2 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
300 KB |
Output is correct |
9 |
Correct |
0 ms |
296 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
5 ms |
352 KB |
Output is correct |
15 |
Correct |
2 ms |
212 KB |
Output is correct |
16 |
Correct |
2 ms |
212 KB |
Output is correct |
17 |
Correct |
3 ms |
308 KB |
Output is correct |
18 |
Correct |
2 ms |
212 KB |
Output is correct |
19 |
Correct |
2 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
300 KB |
Output is correct |
22 |
Correct |
3 ms |
308 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
2 ms |
292 KB |
Output is correct |
25 |
Correct |
2 ms |
212 KB |
Output is correct |
26 |
Correct |
1505 ms |
888 KB |
Output is correct |
27 |
Correct |
973 ms |
716 KB |
Output is correct |
28 |
Correct |
919 ms |
724 KB |
Output is correct |
29 |
Correct |
739 ms |
656 KB |
Output is correct |
30 |
Correct |
415 ms |
540 KB |
Output is correct |
31 |
Correct |
489 ms |
540 KB |
Output is correct |
32 |
Correct |
88 ms |
472 KB |
Output is correct |
33 |
Correct |
123 ms |
580 KB |
Output is correct |
34 |
Correct |
1397 ms |
888 KB |
Output is correct |
35 |
Correct |
10 ms |
340 KB |
Output is correct |
36 |
Correct |
11 ms |
340 KB |
Output is correct |
37 |
Correct |
524 ms |
564 KB |
Output is correct |
38 |
Correct |
534 ms |
568 KB |
Output is correct |
39 |
Correct |
9 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
58 ms |
4372 KB |
Output is correct |
12 |
Correct |
37 ms |
2460 KB |
Output is correct |
13 |
Correct |
44 ms |
2532 KB |
Output is correct |
14 |
Correct |
58 ms |
4380 KB |
Output is correct |
15 |
Correct |
54 ms |
4276 KB |
Output is correct |
16 |
Correct |
51 ms |
4304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
58 ms |
4372 KB |
Output is correct |
12 |
Correct |
37 ms |
2460 KB |
Output is correct |
13 |
Correct |
44 ms |
2532 KB |
Output is correct |
14 |
Correct |
58 ms |
4380 KB |
Output is correct |
15 |
Correct |
54 ms |
4276 KB |
Output is correct |
16 |
Correct |
51 ms |
4304 KB |
Output is correct |
17 |
Correct |
1 ms |
300 KB |
Output is correct |
18 |
Correct |
1 ms |
300 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
8 ms |
380 KB |
Output is correct |
22 |
Correct |
173 ms |
4512 KB |
Output is correct |
23 |
Correct |
73 ms |
4428 KB |
Output is correct |
24 |
Correct |
50 ms |
2564 KB |
Output is correct |
25 |
Correct |
71 ms |
4520 KB |
Output is correct |
26 |
Correct |
57 ms |
4456 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
58 ms |
4372 KB |
Output is correct |
12 |
Correct |
37 ms |
2460 KB |
Output is correct |
13 |
Correct |
44 ms |
2532 KB |
Output is correct |
14 |
Correct |
58 ms |
4380 KB |
Output is correct |
15 |
Correct |
54 ms |
4276 KB |
Output is correct |
16 |
Correct |
51 ms |
4304 KB |
Output is correct |
17 |
Correct |
1 ms |
300 KB |
Output is correct |
18 |
Correct |
1 ms |
300 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
8 ms |
380 KB |
Output is correct |
22 |
Correct |
173 ms |
4512 KB |
Output is correct |
23 |
Correct |
73 ms |
4428 KB |
Output is correct |
24 |
Correct |
50 ms |
2564 KB |
Output is correct |
25 |
Correct |
71 ms |
4520 KB |
Output is correct |
26 |
Correct |
57 ms |
4456 KB |
Output is correct |
27 |
Correct |
2 ms |
212 KB |
Output is correct |
28 |
Correct |
2 ms |
212 KB |
Output is correct |
29 |
Correct |
2 ms |
296 KB |
Output is correct |
30 |
Correct |
2 ms |
212 KB |
Output is correct |
31 |
Correct |
92 ms |
468 KB |
Output is correct |
32 |
Correct |
10 ms |
360 KB |
Output is correct |
33 |
Correct |
11 ms |
340 KB |
Output is correct |
34 |
Execution timed out |
2064 ms |
5936 KB |
Time limit exceeded |
35 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
58 ms |
4372 KB |
Output is correct |
12 |
Correct |
37 ms |
2460 KB |
Output is correct |
13 |
Correct |
44 ms |
2532 KB |
Output is correct |
14 |
Correct |
58 ms |
4380 KB |
Output is correct |
15 |
Correct |
54 ms |
4276 KB |
Output is correct |
16 |
Correct |
51 ms |
4304 KB |
Output is correct |
17 |
Correct |
1 ms |
300 KB |
Output is correct |
18 |
Correct |
1 ms |
300 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
8 ms |
380 KB |
Output is correct |
22 |
Correct |
173 ms |
4512 KB |
Output is correct |
23 |
Correct |
73 ms |
4428 KB |
Output is correct |
24 |
Correct |
50 ms |
2564 KB |
Output is correct |
25 |
Correct |
71 ms |
4520 KB |
Output is correct |
26 |
Correct |
57 ms |
4456 KB |
Output is correct |
27 |
Correct |
2 ms |
212 KB |
Output is correct |
28 |
Correct |
2 ms |
212 KB |
Output is correct |
29 |
Correct |
2 ms |
296 KB |
Output is correct |
30 |
Correct |
2 ms |
212 KB |
Output is correct |
31 |
Correct |
92 ms |
468 KB |
Output is correct |
32 |
Correct |
10 ms |
360 KB |
Output is correct |
33 |
Correct |
11 ms |
340 KB |
Output is correct |
34 |
Execution timed out |
2064 ms |
5936 KB |
Time limit exceeded |
35 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
300 KB |
Output is correct |
9 |
Correct |
0 ms |
296 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
5 ms |
352 KB |
Output is correct |
15 |
Correct |
2 ms |
212 KB |
Output is correct |
16 |
Correct |
2 ms |
212 KB |
Output is correct |
17 |
Correct |
3 ms |
308 KB |
Output is correct |
18 |
Correct |
2 ms |
212 KB |
Output is correct |
19 |
Correct |
2 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
300 KB |
Output is correct |
22 |
Correct |
3 ms |
308 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
2 ms |
292 KB |
Output is correct |
25 |
Correct |
2 ms |
212 KB |
Output is correct |
26 |
Correct |
1505 ms |
888 KB |
Output is correct |
27 |
Correct |
973 ms |
716 KB |
Output is correct |
28 |
Correct |
919 ms |
724 KB |
Output is correct |
29 |
Correct |
739 ms |
656 KB |
Output is correct |
30 |
Correct |
415 ms |
540 KB |
Output is correct |
31 |
Correct |
489 ms |
540 KB |
Output is correct |
32 |
Correct |
88 ms |
472 KB |
Output is correct |
33 |
Correct |
123 ms |
580 KB |
Output is correct |
34 |
Correct |
1397 ms |
888 KB |
Output is correct |
35 |
Correct |
10 ms |
340 KB |
Output is correct |
36 |
Correct |
11 ms |
340 KB |
Output is correct |
37 |
Correct |
524 ms |
564 KB |
Output is correct |
38 |
Correct |
534 ms |
568 KB |
Output is correct |
39 |
Correct |
9 ms |
340 KB |
Output is correct |
40 |
Correct |
1 ms |
212 KB |
Output is correct |
41 |
Correct |
1 ms |
212 KB |
Output is correct |
42 |
Correct |
0 ms |
212 KB |
Output is correct |
43 |
Correct |
1 ms |
212 KB |
Output is correct |
44 |
Correct |
0 ms |
212 KB |
Output is correct |
45 |
Correct |
0 ms |
212 KB |
Output is correct |
46 |
Correct |
1 ms |
212 KB |
Output is correct |
47 |
Correct |
0 ms |
300 KB |
Output is correct |
48 |
Correct |
1 ms |
212 KB |
Output is correct |
49 |
Correct |
1 ms |
212 KB |
Output is correct |
50 |
Correct |
58 ms |
4372 KB |
Output is correct |
51 |
Correct |
37 ms |
2460 KB |
Output is correct |
52 |
Correct |
44 ms |
2532 KB |
Output is correct |
53 |
Correct |
58 ms |
4380 KB |
Output is correct |
54 |
Correct |
54 ms |
4276 KB |
Output is correct |
55 |
Correct |
51 ms |
4304 KB |
Output is correct |
56 |
Correct |
1 ms |
300 KB |
Output is correct |
57 |
Correct |
1 ms |
300 KB |
Output is correct |
58 |
Correct |
1 ms |
212 KB |
Output is correct |
59 |
Correct |
1 ms |
212 KB |
Output is correct |
60 |
Correct |
8 ms |
380 KB |
Output is correct |
61 |
Correct |
173 ms |
4512 KB |
Output is correct |
62 |
Correct |
73 ms |
4428 KB |
Output is correct |
63 |
Correct |
50 ms |
2564 KB |
Output is correct |
64 |
Correct |
71 ms |
4520 KB |
Output is correct |
65 |
Correct |
57 ms |
4456 KB |
Output is correct |
66 |
Correct |
2 ms |
212 KB |
Output is correct |
67 |
Correct |
2 ms |
212 KB |
Output is correct |
68 |
Correct |
2 ms |
296 KB |
Output is correct |
69 |
Correct |
2 ms |
212 KB |
Output is correct |
70 |
Correct |
92 ms |
468 KB |
Output is correct |
71 |
Correct |
10 ms |
360 KB |
Output is correct |
72 |
Correct |
11 ms |
340 KB |
Output is correct |
73 |
Execution timed out |
2064 ms |
5936 KB |
Time limit exceeded |
74 |
Halted |
0 ms |
0 KB |
- |