#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int inf = 1e9;
int mn[305], mx[305];
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
int n;
cin >> n;
array<int, 3> a[n];
for (int i = 0; i < n; i++) {
cin >> a[i][0] >> a[i][1] >> a[i][2];
}
sort(a, a + n);
int ans = -1;
int cur = 0;
for (int i = 0; i < 305; i++) {
mn[i] = inf;
mx[i] = -inf;
}
for (int i = 0; i < n; i++) {
while (a[cur][0] < a[i][0]) {
mx[a[cur][1]] = max(mx[a[cur][1]], a[cur][2]);
mn[a[cur][1]] = min(mn[a[cur][1]], a[cur][2]);
cur++;
}
int sufxmx[305]{};
sufxmx[0] = mx[0];
for (int y = 1; y < 305; y++) {
sufxmx[y] = max(sufxmx[y - 1], mx[y]);
}
int curmn = inf;
for (int y = 304; y >= max(1, a[i][1] + 1); y--) {
curmn = min(curmn, mn[y]);
if (curmn != inf && sufxmx[y - 1] != -inf && curmn < sufxmx[y - 1] && a[i][2] < sufxmx[y - 1]) {
ans = max(ans, a[i][0] + sufxmx[y - 1] + y);
break;
}
}
}
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
444 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
134 ms |
2140 KB |
Output is correct |
12 |
Correct |
81 ms |
2196 KB |
Output is correct |
13 |
Correct |
99 ms |
2392 KB |
Output is correct |
14 |
Correct |
161 ms |
3072 KB |
Output is correct |
15 |
Correct |
120 ms |
3072 KB |
Output is correct |
16 |
Correct |
117 ms |
3072 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
444 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
134 ms |
2140 KB |
Output is correct |
12 |
Correct |
81 ms |
2196 KB |
Output is correct |
13 |
Correct |
99 ms |
2392 KB |
Output is correct |
14 |
Correct |
161 ms |
3072 KB |
Output is correct |
15 |
Correct |
120 ms |
3072 KB |
Output is correct |
16 |
Correct |
117 ms |
3072 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
460 KB |
Output is correct |
21 |
Correct |
2 ms |
344 KB |
Output is correct |
22 |
Correct |
135 ms |
3316 KB |
Output is correct |
23 |
Correct |
126 ms |
2908 KB |
Output is correct |
24 |
Correct |
93 ms |
2388 KB |
Output is correct |
25 |
Correct |
127 ms |
3332 KB |
Output is correct |
26 |
Correct |
121 ms |
3188 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
444 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
134 ms |
2140 KB |
Output is correct |
12 |
Correct |
81 ms |
2196 KB |
Output is correct |
13 |
Correct |
99 ms |
2392 KB |
Output is correct |
14 |
Correct |
161 ms |
3072 KB |
Output is correct |
15 |
Correct |
120 ms |
3072 KB |
Output is correct |
16 |
Correct |
117 ms |
3072 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
460 KB |
Output is correct |
21 |
Correct |
2 ms |
344 KB |
Output is correct |
22 |
Correct |
135 ms |
3316 KB |
Output is correct |
23 |
Correct |
126 ms |
2908 KB |
Output is correct |
24 |
Correct |
93 ms |
2388 KB |
Output is correct |
25 |
Correct |
127 ms |
3332 KB |
Output is correct |
26 |
Correct |
121 ms |
3188 KB |
Output is correct |
27 |
Correct |
1 ms |
708 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
3 ms |
348 KB |
Output is correct |
32 |
Correct |
1 ms |
464 KB |
Output is correct |
33 |
Correct |
1 ms |
344 KB |
Output is correct |
34 |
Correct |
86 ms |
3656 KB |
Output is correct |
35 |
Correct |
119 ms |
3452 KB |
Output is correct |
36 |
Correct |
111 ms |
3676 KB |
Output is correct |
37 |
Correct |
116 ms |
3852 KB |
Output is correct |
38 |
Correct |
97 ms |
3696 KB |
Output is correct |
39 |
Correct |
71 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
444 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
134 ms |
2140 KB |
Output is correct |
12 |
Correct |
81 ms |
2196 KB |
Output is correct |
13 |
Correct |
99 ms |
2392 KB |
Output is correct |
14 |
Correct |
161 ms |
3072 KB |
Output is correct |
15 |
Correct |
120 ms |
3072 KB |
Output is correct |
16 |
Correct |
117 ms |
3072 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
460 KB |
Output is correct |
21 |
Correct |
2 ms |
344 KB |
Output is correct |
22 |
Correct |
135 ms |
3316 KB |
Output is correct |
23 |
Correct |
126 ms |
2908 KB |
Output is correct |
24 |
Correct |
93 ms |
2388 KB |
Output is correct |
25 |
Correct |
127 ms |
3332 KB |
Output is correct |
26 |
Correct |
121 ms |
3188 KB |
Output is correct |
27 |
Correct |
1 ms |
708 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
3 ms |
348 KB |
Output is correct |
32 |
Correct |
1 ms |
464 KB |
Output is correct |
33 |
Correct |
1 ms |
344 KB |
Output is correct |
34 |
Correct |
86 ms |
3656 KB |
Output is correct |
35 |
Correct |
119 ms |
3452 KB |
Output is correct |
36 |
Correct |
111 ms |
3676 KB |
Output is correct |
37 |
Correct |
116 ms |
3852 KB |
Output is correct |
38 |
Correct |
97 ms |
3696 KB |
Output is correct |
39 |
Correct |
71 ms |
2396 KB |
Output is correct |
40 |
Runtime error |
2 ms |
600 KB |
Execution killed with signal 11 |
41 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
15 |
Halted |
0 ms |
0 KB |
- |