/**
_ _ __ _ _ _ _ _ _
|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 a = N, b = N; a >= 1; a--) {
int i = order[a];
while (b >= 1 && X[i] == X[order[b]]) {
int i = order[b--];
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2516 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2508 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2472 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 ms |
2392 KB |
Output is correct |
22 |
Correct |
1 ms |
2512 KB |
Output is correct |
23 |
Correct |
1 ms |
2396 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2516 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2508 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2472 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 ms |
2392 KB |
Output is correct |
22 |
Correct |
1 ms |
2512 KB |
Output is correct |
23 |
Correct |
1 ms |
2396 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
1 ms |
2396 KB |
Output is correct |
26 |
Correct |
5 ms |
2904 KB |
Output is correct |
27 |
Correct |
4 ms |
2908 KB |
Output is correct |
28 |
Correct |
4 ms |
2908 KB |
Output is correct |
29 |
Correct |
4 ms |
2908 KB |
Output is correct |
30 |
Correct |
2 ms |
2804 KB |
Output is correct |
31 |
Correct |
4 ms |
2816 KB |
Output is correct |
32 |
Correct |
4 ms |
2908 KB |
Output is correct |
33 |
Correct |
4 ms |
2908 KB |
Output is correct |
34 |
Correct |
3 ms |
2904 KB |
Output is correct |
35 |
Correct |
1 ms |
2396 KB |
Output is correct |
36 |
Correct |
1 ms |
2396 KB |
Output is correct |
37 |
Correct |
2 ms |
2908 KB |
Output is correct |
38 |
Correct |
3 ms |
2908 KB |
Output is correct |
39 |
Correct |
2 ms |
2652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
134 ms |
17752 KB |
Output is correct |
12 |
Correct |
71 ms |
12648 KB |
Output is correct |
13 |
Correct |
69 ms |
15008 KB |
Output is correct |
14 |
Correct |
119 ms |
17744 KB |
Output is correct |
15 |
Correct |
98 ms |
17760 KB |
Output is correct |
16 |
Correct |
88 ms |
17748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
134 ms |
17752 KB |
Output is correct |
12 |
Correct |
71 ms |
12648 KB |
Output is correct |
13 |
Correct |
69 ms |
15008 KB |
Output is correct |
14 |
Correct |
119 ms |
17744 KB |
Output is correct |
15 |
Correct |
98 ms |
17760 KB |
Output is correct |
16 |
Correct |
88 ms |
17748 KB |
Output is correct |
17 |
Correct |
1 ms |
2392 KB |
Output is correct |
18 |
Correct |
0 ms |
2396 KB |
Output is correct |
19 |
Correct |
0 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
3 ms |
2652 KB |
Output is correct |
22 |
Correct |
240 ms |
18004 KB |
Output is correct |
23 |
Correct |
190 ms |
17448 KB |
Output is correct |
24 |
Correct |
125 ms |
13428 KB |
Output is correct |
25 |
Correct |
144 ms |
17852 KB |
Output is correct |
26 |
Correct |
109 ms |
17748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
134 ms |
17752 KB |
Output is correct |
12 |
Correct |
71 ms |
12648 KB |
Output is correct |
13 |
Correct |
69 ms |
15008 KB |
Output is correct |
14 |
Correct |
119 ms |
17744 KB |
Output is correct |
15 |
Correct |
98 ms |
17760 KB |
Output is correct |
16 |
Correct |
88 ms |
17748 KB |
Output is correct |
17 |
Correct |
1 ms |
2392 KB |
Output is correct |
18 |
Correct |
0 ms |
2396 KB |
Output is correct |
19 |
Correct |
0 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
3 ms |
2652 KB |
Output is correct |
22 |
Correct |
240 ms |
18004 KB |
Output is correct |
23 |
Correct |
190 ms |
17448 KB |
Output is correct |
24 |
Correct |
125 ms |
13428 KB |
Output is correct |
25 |
Correct |
144 ms |
17852 KB |
Output is correct |
26 |
Correct |
109 ms |
17748 KB |
Output is correct |
27 |
Correct |
1 ms |
2396 KB |
Output is correct |
28 |
Correct |
1 ms |
2396 KB |
Output is correct |
29 |
Correct |
1 ms |
2396 KB |
Output is correct |
30 |
Correct |
1 ms |
2396 KB |
Output is correct |
31 |
Correct |
4 ms |
2908 KB |
Output is correct |
32 |
Correct |
1 ms |
2396 KB |
Output is correct |
33 |
Correct |
1 ms |
2392 KB |
Output is correct |
34 |
Correct |
234 ms |
17640 KB |
Output is correct |
35 |
Correct |
182 ms |
16852 KB |
Output is correct |
36 |
Correct |
307 ms |
18412 KB |
Output is correct |
37 |
Correct |
174 ms |
18236 KB |
Output is correct |
38 |
Correct |
117 ms |
18156 KB |
Output is correct |
39 |
Correct |
52 ms |
12116 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
134 ms |
17752 KB |
Output is correct |
12 |
Correct |
71 ms |
12648 KB |
Output is correct |
13 |
Correct |
69 ms |
15008 KB |
Output is correct |
14 |
Correct |
119 ms |
17744 KB |
Output is correct |
15 |
Correct |
98 ms |
17760 KB |
Output is correct |
16 |
Correct |
88 ms |
17748 KB |
Output is correct |
17 |
Correct |
1 ms |
2392 KB |
Output is correct |
18 |
Correct |
0 ms |
2396 KB |
Output is correct |
19 |
Correct |
0 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
3 ms |
2652 KB |
Output is correct |
22 |
Correct |
240 ms |
18004 KB |
Output is correct |
23 |
Correct |
190 ms |
17448 KB |
Output is correct |
24 |
Correct |
125 ms |
13428 KB |
Output is correct |
25 |
Correct |
144 ms |
17852 KB |
Output is correct |
26 |
Correct |
109 ms |
17748 KB |
Output is correct |
27 |
Correct |
1 ms |
2396 KB |
Output is correct |
28 |
Correct |
1 ms |
2396 KB |
Output is correct |
29 |
Correct |
1 ms |
2396 KB |
Output is correct |
30 |
Correct |
1 ms |
2396 KB |
Output is correct |
31 |
Correct |
4 ms |
2908 KB |
Output is correct |
32 |
Correct |
1 ms |
2396 KB |
Output is correct |
33 |
Correct |
1 ms |
2392 KB |
Output is correct |
34 |
Correct |
234 ms |
17640 KB |
Output is correct |
35 |
Correct |
182 ms |
16852 KB |
Output is correct |
36 |
Correct |
307 ms |
18412 KB |
Output is correct |
37 |
Correct |
174 ms |
18236 KB |
Output is correct |
38 |
Correct |
117 ms |
18156 KB |
Output is correct |
39 |
Correct |
52 ms |
12116 KB |
Output is correct |
40 |
Correct |
2 ms |
2652 KB |
Output is correct |
41 |
Correct |
4 ms |
2892 KB |
Output is correct |
42 |
Correct |
3 ms |
2908 KB |
Output is correct |
43 |
Correct |
3 ms |
2908 KB |
Output is correct |
44 |
Correct |
231 ms |
18752 KB |
Output is correct |
45 |
Correct |
198 ms |
18988 KB |
Output is correct |
46 |
Correct |
197 ms |
18732 KB |
Output is correct |
47 |
Correct |
190 ms |
18852 KB |
Output is correct |
48 |
Correct |
120 ms |
18772 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2516 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2508 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2472 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 ms |
2392 KB |
Output is correct |
22 |
Correct |
1 ms |
2512 KB |
Output is correct |
23 |
Correct |
1 ms |
2396 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
1 ms |
2396 KB |
Output is correct |
26 |
Correct |
5 ms |
2904 KB |
Output is correct |
27 |
Correct |
4 ms |
2908 KB |
Output is correct |
28 |
Correct |
4 ms |
2908 KB |
Output is correct |
29 |
Correct |
4 ms |
2908 KB |
Output is correct |
30 |
Correct |
2 ms |
2804 KB |
Output is correct |
31 |
Correct |
4 ms |
2816 KB |
Output is correct |
32 |
Correct |
4 ms |
2908 KB |
Output is correct |
33 |
Correct |
4 ms |
2908 KB |
Output is correct |
34 |
Correct |
3 ms |
2904 KB |
Output is correct |
35 |
Correct |
1 ms |
2396 KB |
Output is correct |
36 |
Correct |
1 ms |
2396 KB |
Output is correct |
37 |
Correct |
2 ms |
2908 KB |
Output is correct |
38 |
Correct |
3 ms |
2908 KB |
Output is correct |
39 |
Correct |
2 ms |
2652 KB |
Output is correct |
40 |
Correct |
1 ms |
2396 KB |
Output is correct |
41 |
Correct |
1 ms |
2396 KB |
Output is correct |
42 |
Correct |
0 ms |
2396 KB |
Output is correct |
43 |
Correct |
1 ms |
2396 KB |
Output is correct |
44 |
Correct |
1 ms |
2396 KB |
Output is correct |
45 |
Correct |
0 ms |
2396 KB |
Output is correct |
46 |
Correct |
1 ms |
2396 KB |
Output is correct |
47 |
Correct |
1 ms |
2396 KB |
Output is correct |
48 |
Correct |
1 ms |
2396 KB |
Output is correct |
49 |
Correct |
0 ms |
2396 KB |
Output is correct |
50 |
Correct |
134 ms |
17752 KB |
Output is correct |
51 |
Correct |
71 ms |
12648 KB |
Output is correct |
52 |
Correct |
69 ms |
15008 KB |
Output is correct |
53 |
Correct |
119 ms |
17744 KB |
Output is correct |
54 |
Correct |
98 ms |
17760 KB |
Output is correct |
55 |
Correct |
88 ms |
17748 KB |
Output is correct |
56 |
Correct |
1 ms |
2392 KB |
Output is correct |
57 |
Correct |
0 ms |
2396 KB |
Output is correct |
58 |
Correct |
0 ms |
2396 KB |
Output is correct |
59 |
Correct |
1 ms |
2396 KB |
Output is correct |
60 |
Correct |
3 ms |
2652 KB |
Output is correct |
61 |
Correct |
240 ms |
18004 KB |
Output is correct |
62 |
Correct |
190 ms |
17448 KB |
Output is correct |
63 |
Correct |
125 ms |
13428 KB |
Output is correct |
64 |
Correct |
144 ms |
17852 KB |
Output is correct |
65 |
Correct |
109 ms |
17748 KB |
Output is correct |
66 |
Correct |
1 ms |
2396 KB |
Output is correct |
67 |
Correct |
1 ms |
2396 KB |
Output is correct |
68 |
Correct |
1 ms |
2396 KB |
Output is correct |
69 |
Correct |
1 ms |
2396 KB |
Output is correct |
70 |
Correct |
4 ms |
2908 KB |
Output is correct |
71 |
Correct |
1 ms |
2396 KB |
Output is correct |
72 |
Correct |
1 ms |
2392 KB |
Output is correct |
73 |
Correct |
234 ms |
17640 KB |
Output is correct |
74 |
Correct |
182 ms |
16852 KB |
Output is correct |
75 |
Correct |
307 ms |
18412 KB |
Output is correct |
76 |
Correct |
174 ms |
18236 KB |
Output is correct |
77 |
Correct |
117 ms |
18156 KB |
Output is correct |
78 |
Correct |
52 ms |
12116 KB |
Output is correct |
79 |
Correct |
2 ms |
2652 KB |
Output is correct |
80 |
Correct |
4 ms |
2892 KB |
Output is correct |
81 |
Correct |
3 ms |
2908 KB |
Output is correct |
82 |
Correct |
3 ms |
2908 KB |
Output is correct |
83 |
Correct |
231 ms |
18752 KB |
Output is correct |
84 |
Correct |
198 ms |
18988 KB |
Output is correct |
85 |
Correct |
197 ms |
18732 KB |
Output is correct |
86 |
Correct |
190 ms |
18852 KB |
Output is correct |
87 |
Correct |
120 ms |
18772 KB |
Output is correct |
88 |
Correct |
237 ms |
20560 KB |
Output is correct |
89 |
Correct |
218 ms |
20560 KB |
Output is correct |
90 |
Correct |
212 ms |
20560 KB |
Output is correct |
91 |
Correct |
184 ms |
20564 KB |
Output is correct |
92 |
Correct |
259 ms |
19340 KB |
Output is correct |
93 |
Correct |
192 ms |
19540 KB |
Output is correct |
94 |
Correct |
194 ms |
19492 KB |
Output is correct |
95 |
Correct |
133 ms |
20536 KB |
Output is correct |
96 |
Correct |
121 ms |
20552 KB |
Output is correct |
97 |
Correct |
104 ms |
20816 KB |
Output is correct |
98 |
Correct |
82 ms |
19284 KB |
Output is correct |
99 |
Correct |
101 ms |
19264 KB |
Output is correct |