#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
const int N = 2e5 + 69;
const int A = 550;
const int inf = 1e9;
int n, a[N], b[N], c[N], d[A][A];
int gmx[A][A], gmn[A][A], mn[A][A];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tt = 1;
//cin >> tt;
while (tt--) {
cin >> n;
for (int i = 1;i <= n;i++)
cin >> a[i] >> b[i] >> c[i];
for (int i = 0;i < A;i++) {
for (int j = 0;j < A;j++) {
gmn[i][j] = inf;
gmx[i][j] = -inf;
d[i][j] = -inf;
mn[i][j] = inf;
}
}
for (int i = 1;i <= n;i++) {
gmx[a[i]][b[i]] = max(c[i], gmx[a[i]][b[i]]);
gmn[a[i]][b[i]] = min(c[i], gmn[a[i]][b[i]]);
}
for (int i = 1;i < A;i++) {
for (int j = 1;j < A;j++) {
d[i][j] = max({d[i][j - 1], d[i - 1][j], gmx[i][j]});
mn[i][j] = min(mn[i][j - 1], gmn[i][j]);
}
}
int ans = -1;
for (int i = 1;i <= n;i++) {
for (int j = a[i] + 1;j < A;j++) {
if (mn[j][b[i] - 1] < d[j - 1][b[i] - 1] && d[j - 1][b[i] - 1] > c[i]) {
ans = max(ans, b[i] + j + d[j - 1][b[i] - 1]);
}
}
}
cout << ans << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
6748 KB |
Output is correct |
2 |
Correct |
3 ms |
6748 KB |
Output is correct |
3 |
Correct |
3 ms |
6744 KB |
Output is correct |
4 |
Correct |
2 ms |
6748 KB |
Output is correct |
5 |
Correct |
2 ms |
6748 KB |
Output is correct |
6 |
Correct |
3 ms |
6604 KB |
Output is correct |
7 |
Correct |
3 ms |
6748 KB |
Output is correct |
8 |
Correct |
3 ms |
6744 KB |
Output is correct |
9 |
Correct |
3 ms |
6744 KB |
Output is correct |
10 |
Correct |
3 ms |
6744 KB |
Output is correct |
11 |
Correct |
3 ms |
6748 KB |
Output is correct |
12 |
Correct |
3 ms |
6748 KB |
Output is correct |
13 |
Correct |
3 ms |
6748 KB |
Output is correct |
14 |
Runtime error |
7 ms |
13404 KB |
Execution killed with signal 11 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
6748 KB |
Output is correct |
2 |
Correct |
3 ms |
6748 KB |
Output is correct |
3 |
Correct |
3 ms |
6744 KB |
Output is correct |
4 |
Correct |
2 ms |
6748 KB |
Output is correct |
5 |
Correct |
2 ms |
6748 KB |
Output is correct |
6 |
Correct |
3 ms |
6604 KB |
Output is correct |
7 |
Correct |
3 ms |
6748 KB |
Output is correct |
8 |
Correct |
3 ms |
6744 KB |
Output is correct |
9 |
Correct |
3 ms |
6744 KB |
Output is correct |
10 |
Correct |
3 ms |
6744 KB |
Output is correct |
11 |
Correct |
3 ms |
6748 KB |
Output is correct |
12 |
Correct |
3 ms |
6748 KB |
Output is correct |
13 |
Correct |
3 ms |
6748 KB |
Output is correct |
14 |
Runtime error |
7 ms |
13404 KB |
Execution killed with signal 11 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
6748 KB |
Output is correct |
2 |
Correct |
3 ms |
6792 KB |
Output is correct |
3 |
Correct |
3 ms |
6748 KB |
Output is correct |
4 |
Correct |
3 ms |
6748 KB |
Output is correct |
5 |
Correct |
3 ms |
6792 KB |
Output is correct |
6 |
Correct |
3 ms |
6748 KB |
Output is correct |
7 |
Correct |
3 ms |
6608 KB |
Output is correct |
8 |
Correct |
3 ms |
6744 KB |
Output is correct |
9 |
Correct |
3 ms |
6748 KB |
Output is correct |
10 |
Correct |
3 ms |
6744 KB |
Output is correct |
11 |
Correct |
122 ms |
7328 KB |
Output is correct |
12 |
Correct |
82 ms |
7004 KB |
Output is correct |
13 |
Correct |
109 ms |
7784 KB |
Output is correct |
14 |
Correct |
122 ms |
8204 KB |
Output is correct |
15 |
Correct |
123 ms |
8212 KB |
Output is correct |
16 |
Correct |
124 ms |
8204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
6748 KB |
Output is correct |
2 |
Correct |
3 ms |
6792 KB |
Output is correct |
3 |
Correct |
3 ms |
6748 KB |
Output is correct |
4 |
Correct |
3 ms |
6748 KB |
Output is correct |
5 |
Correct |
3 ms |
6792 KB |
Output is correct |
6 |
Correct |
3 ms |
6748 KB |
Output is correct |
7 |
Correct |
3 ms |
6608 KB |
Output is correct |
8 |
Correct |
3 ms |
6744 KB |
Output is correct |
9 |
Correct |
3 ms |
6748 KB |
Output is correct |
10 |
Correct |
3 ms |
6744 KB |
Output is correct |
11 |
Correct |
122 ms |
7328 KB |
Output is correct |
12 |
Correct |
82 ms |
7004 KB |
Output is correct |
13 |
Correct |
109 ms |
7784 KB |
Output is correct |
14 |
Correct |
122 ms |
8204 KB |
Output is correct |
15 |
Correct |
123 ms |
8212 KB |
Output is correct |
16 |
Correct |
124 ms |
8204 KB |
Output is correct |
17 |
Correct |
3 ms |
6748 KB |
Output is correct |
18 |
Correct |
3 ms |
6796 KB |
Output is correct |
19 |
Correct |
3 ms |
6748 KB |
Output is correct |
20 |
Correct |
3 ms |
6748 KB |
Output is correct |
21 |
Correct |
4 ms |
6748 KB |
Output is correct |
22 |
Correct |
131 ms |
8456 KB |
Output is correct |
23 |
Correct |
119 ms |
8028 KB |
Output is correct |
24 |
Correct |
106 ms |
7772 KB |
Output is correct |
25 |
Correct |
123 ms |
8280 KB |
Output is correct |
26 |
Correct |
121 ms |
8324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
6748 KB |
Output is correct |
2 |
Correct |
3 ms |
6792 KB |
Output is correct |
3 |
Correct |
3 ms |
6748 KB |
Output is correct |
4 |
Correct |
3 ms |
6748 KB |
Output is correct |
5 |
Correct |
3 ms |
6792 KB |
Output is correct |
6 |
Correct |
3 ms |
6748 KB |
Output is correct |
7 |
Correct |
3 ms |
6608 KB |
Output is correct |
8 |
Correct |
3 ms |
6744 KB |
Output is correct |
9 |
Correct |
3 ms |
6748 KB |
Output is correct |
10 |
Correct |
3 ms |
6744 KB |
Output is correct |
11 |
Correct |
122 ms |
7328 KB |
Output is correct |
12 |
Correct |
82 ms |
7004 KB |
Output is correct |
13 |
Correct |
109 ms |
7784 KB |
Output is correct |
14 |
Correct |
122 ms |
8204 KB |
Output is correct |
15 |
Correct |
123 ms |
8212 KB |
Output is correct |
16 |
Correct |
124 ms |
8204 KB |
Output is correct |
17 |
Correct |
3 ms |
6748 KB |
Output is correct |
18 |
Correct |
3 ms |
6796 KB |
Output is correct |
19 |
Correct |
3 ms |
6748 KB |
Output is correct |
20 |
Correct |
3 ms |
6748 KB |
Output is correct |
21 |
Correct |
4 ms |
6748 KB |
Output is correct |
22 |
Correct |
131 ms |
8456 KB |
Output is correct |
23 |
Correct |
119 ms |
8028 KB |
Output is correct |
24 |
Correct |
106 ms |
7772 KB |
Output is correct |
25 |
Correct |
123 ms |
8280 KB |
Output is correct |
26 |
Correct |
121 ms |
8324 KB |
Output is correct |
27 |
Correct |
3 ms |
6748 KB |
Output is correct |
28 |
Correct |
3 ms |
6748 KB |
Output is correct |
29 |
Correct |
3 ms |
6612 KB |
Output is correct |
30 |
Correct |
3 ms |
6748 KB |
Output is correct |
31 |
Correct |
5 ms |
6748 KB |
Output is correct |
32 |
Correct |
3 ms |
6744 KB |
Output is correct |
33 |
Correct |
3 ms |
6748 KB |
Output is correct |
34 |
Correct |
114 ms |
8796 KB |
Output is correct |
35 |
Correct |
106 ms |
8536 KB |
Output is correct |
36 |
Correct |
128 ms |
8864 KB |
Output is correct |
37 |
Correct |
98 ms |
8784 KB |
Output is correct |
38 |
Correct |
71 ms |
8796 KB |
Output is correct |
39 |
Correct |
31 ms |
8016 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
6748 KB |
Output is correct |
2 |
Correct |
3 ms |
6792 KB |
Output is correct |
3 |
Correct |
3 ms |
6748 KB |
Output is correct |
4 |
Correct |
3 ms |
6748 KB |
Output is correct |
5 |
Correct |
3 ms |
6792 KB |
Output is correct |
6 |
Correct |
3 ms |
6748 KB |
Output is correct |
7 |
Correct |
3 ms |
6608 KB |
Output is correct |
8 |
Correct |
3 ms |
6744 KB |
Output is correct |
9 |
Correct |
3 ms |
6748 KB |
Output is correct |
10 |
Correct |
3 ms |
6744 KB |
Output is correct |
11 |
Correct |
122 ms |
7328 KB |
Output is correct |
12 |
Correct |
82 ms |
7004 KB |
Output is correct |
13 |
Correct |
109 ms |
7784 KB |
Output is correct |
14 |
Correct |
122 ms |
8204 KB |
Output is correct |
15 |
Correct |
123 ms |
8212 KB |
Output is correct |
16 |
Correct |
124 ms |
8204 KB |
Output is correct |
17 |
Correct |
3 ms |
6748 KB |
Output is correct |
18 |
Correct |
3 ms |
6796 KB |
Output is correct |
19 |
Correct |
3 ms |
6748 KB |
Output is correct |
20 |
Correct |
3 ms |
6748 KB |
Output is correct |
21 |
Correct |
4 ms |
6748 KB |
Output is correct |
22 |
Correct |
131 ms |
8456 KB |
Output is correct |
23 |
Correct |
119 ms |
8028 KB |
Output is correct |
24 |
Correct |
106 ms |
7772 KB |
Output is correct |
25 |
Correct |
123 ms |
8280 KB |
Output is correct |
26 |
Correct |
121 ms |
8324 KB |
Output is correct |
27 |
Correct |
3 ms |
6748 KB |
Output is correct |
28 |
Correct |
3 ms |
6748 KB |
Output is correct |
29 |
Correct |
3 ms |
6612 KB |
Output is correct |
30 |
Correct |
3 ms |
6748 KB |
Output is correct |
31 |
Correct |
5 ms |
6748 KB |
Output is correct |
32 |
Correct |
3 ms |
6744 KB |
Output is correct |
33 |
Correct |
3 ms |
6748 KB |
Output is correct |
34 |
Correct |
114 ms |
8796 KB |
Output is correct |
35 |
Correct |
106 ms |
8536 KB |
Output is correct |
36 |
Correct |
128 ms |
8864 KB |
Output is correct |
37 |
Correct |
98 ms |
8784 KB |
Output is correct |
38 |
Correct |
71 ms |
8796 KB |
Output is correct |
39 |
Correct |
31 ms |
8016 KB |
Output is correct |
40 |
Runtime error |
8 ms |
13404 KB |
Execution killed with signal 11 |
41 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
6748 KB |
Output is correct |
2 |
Correct |
3 ms |
6748 KB |
Output is correct |
3 |
Correct |
3 ms |
6744 KB |
Output is correct |
4 |
Correct |
2 ms |
6748 KB |
Output is correct |
5 |
Correct |
2 ms |
6748 KB |
Output is correct |
6 |
Correct |
3 ms |
6604 KB |
Output is correct |
7 |
Correct |
3 ms |
6748 KB |
Output is correct |
8 |
Correct |
3 ms |
6744 KB |
Output is correct |
9 |
Correct |
3 ms |
6744 KB |
Output is correct |
10 |
Correct |
3 ms |
6744 KB |
Output is correct |
11 |
Correct |
3 ms |
6748 KB |
Output is correct |
12 |
Correct |
3 ms |
6748 KB |
Output is correct |
13 |
Correct |
3 ms |
6748 KB |
Output is correct |
14 |
Runtime error |
7 ms |
13404 KB |
Execution killed with signal 11 |
15 |
Halted |
0 ms |
0 KB |
- |