#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include<bits/extc++.h>
//__gnu_pbds
const int N = 305;
int Xsum[N][N][N];
int Ysum[N][N][N];
int Zsum[N][N][N];
int main(){
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int n;cin>>n;
if(n>4000){
for(int i=0;i<n;i++){
int a,b,c;cin>>a>>b>>c;
Xsum[a][b][c]++;
Ysum[b][a][c]++;
Zsum[c][a][b]++;
}
for(int i=1;i<N;i++){
for(int j=1;j<N;j++){
for(int k=1;k<N;k++){
Xsum[i][j][k] = Xsum[i][j][k]+Xsum[i][j-1][k]+Xsum[i][j][k-1]-Xsum[i][j-1][k-1];
Ysum[i][j][k] = Ysum[i][j][k]+Ysum[i][j-1][k]+Ysum[i][j][k-1]-Ysum[i][j-1][k-1];
Zsum[i][j][k] = Zsum[i][j][k]+Zsum[i][j-1][k]+Zsum[i][j][k-1]-Zsum[i][j-1][k-1];
}
}
}
int ans = -1;
for(int i=1;i<N;i++){
for(int j=1;j<N;j++){
for(int k=1;k<N;k++){
if(Xsum[i][j-1][k-1] && Ysum[j][i-1][k-1] && Zsum[k][i-1][j-1]) ans = max(ans,i+j+k);
}
}
}
cout<<ans<<"\n";
return 0;
}else{
vector<int> Y;
vector<int> Z;
vector<int> X;
X.resize(n);
Y.resize(n);
Z.resize(n);
vector<int> w(n);
for(int i=0;i<n;i++) cin>>X[i]>>Y[i]>>Z[i];
for(int i=0;i<n;i++) {w[i]=i;}
sort(w.begin(),w.end(),[&](const int a,const int b){return Y[a]<Y[b];});
int ans = -1;
int prevy = 1e9;
for(int i=0;i<n;i++){
int maxn = -1e9;
vector<int> tadd;
for(int j=0;j<n;j++){
if(X[w[j]]>=X[i]) continue;
if(Y[w[j]]>prevy){
while(tadd.size()){
maxn = max(maxn,Z[tadd.back()]);
tadd.pop_back();
}
}
prevy = Y[w[j]];
tadd.push_back(w[j]);
if(Y[w[j]]>Y[i]){
if(maxn>Z[i] && maxn>Z[w[j]]){
// cout<<i<<" "<<w[j]<<" "<<maxn<<"\n";
ans = max(ans,maxn+Y[w[j]]+X[i]);
}
}
}
}
cout<<ans<<"\n";
return 0;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 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 |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
600 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 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 |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
600 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
92 ms |
504 KB |
Output is correct |
27 |
Correct |
104 ms |
344 KB |
Output is correct |
28 |
Correct |
100 ms |
348 KB |
Output is correct |
29 |
Correct |
90 ms |
504 KB |
Output is correct |
30 |
Correct |
41 ms |
344 KB |
Output is correct |
31 |
Correct |
103 ms |
348 KB |
Output is correct |
32 |
Correct |
90 ms |
348 KB |
Output is correct |
33 |
Correct |
33 ms |
344 KB |
Output is correct |
34 |
Correct |
53 ms |
584 KB |
Output is correct |
35 |
Correct |
3 ms |
344 KB |
Output is correct |
36 |
Correct |
3 ms |
348 KB |
Output is correct |
37 |
Correct |
42 ms |
348 KB |
Output is correct |
38 |
Correct |
42 ms |
344 KB |
Output is correct |
39 |
Correct |
26 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 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 |
246 ms |
333360 KB |
Output is correct |
12 |
Correct |
238 ms |
333404 KB |
Output is correct |
13 |
Correct |
260 ms |
333396 KB |
Output is correct |
14 |
Correct |
243 ms |
333328 KB |
Output is correct |
15 |
Correct |
253 ms |
333200 KB |
Output is correct |
16 |
Correct |
245 ms |
333188 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 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 |
246 ms |
333360 KB |
Output is correct |
12 |
Correct |
238 ms |
333404 KB |
Output is correct |
13 |
Correct |
260 ms |
333396 KB |
Output is correct |
14 |
Correct |
243 ms |
333328 KB |
Output is correct |
15 |
Correct |
253 ms |
333200 KB |
Output is correct |
16 |
Correct |
245 ms |
333188 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
600 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
22 ms |
476 KB |
Output is correct |
22 |
Correct |
248 ms |
333400 KB |
Output is correct |
23 |
Correct |
241 ms |
333396 KB |
Output is correct |
24 |
Correct |
240 ms |
333396 KB |
Output is correct |
25 |
Correct |
270 ms |
333328 KB |
Output is correct |
26 |
Correct |
247 ms |
333316 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 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 |
246 ms |
333360 KB |
Output is correct |
12 |
Correct |
238 ms |
333404 KB |
Output is correct |
13 |
Correct |
260 ms |
333396 KB |
Output is correct |
14 |
Correct |
243 ms |
333328 KB |
Output is correct |
15 |
Correct |
253 ms |
333200 KB |
Output is correct |
16 |
Correct |
245 ms |
333188 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
600 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
22 ms |
476 KB |
Output is correct |
22 |
Correct |
248 ms |
333400 KB |
Output is correct |
23 |
Correct |
241 ms |
333396 KB |
Output is correct |
24 |
Correct |
240 ms |
333396 KB |
Output is correct |
25 |
Correct |
270 ms |
333328 KB |
Output is correct |
26 |
Correct |
247 ms |
333316 KB |
Output is correct |
27 |
Correct |
1 ms |
600 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 |
84 ms |
348 KB |
Output is correct |
32 |
Correct |
3 ms |
344 KB |
Output is correct |
33 |
Correct |
3 ms |
348 KB |
Output is correct |
34 |
Correct |
226 ms |
333140 KB |
Output is correct |
35 |
Correct |
240 ms |
332880 KB |
Output is correct |
36 |
Correct |
232 ms |
333368 KB |
Output is correct |
37 |
Correct |
230 ms |
333144 KB |
Output is correct |
38 |
Correct |
190 ms |
333216 KB |
Output is correct |
39 |
Correct |
179 ms |
333044 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 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 |
246 ms |
333360 KB |
Output is correct |
12 |
Correct |
238 ms |
333404 KB |
Output is correct |
13 |
Correct |
260 ms |
333396 KB |
Output is correct |
14 |
Correct |
243 ms |
333328 KB |
Output is correct |
15 |
Correct |
253 ms |
333200 KB |
Output is correct |
16 |
Correct |
245 ms |
333188 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
600 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
22 ms |
476 KB |
Output is correct |
22 |
Correct |
248 ms |
333400 KB |
Output is correct |
23 |
Correct |
241 ms |
333396 KB |
Output is correct |
24 |
Correct |
240 ms |
333396 KB |
Output is correct |
25 |
Correct |
270 ms |
333328 KB |
Output is correct |
26 |
Correct |
247 ms |
333316 KB |
Output is correct |
27 |
Correct |
1 ms |
600 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 |
84 ms |
348 KB |
Output is correct |
32 |
Correct |
3 ms |
344 KB |
Output is correct |
33 |
Correct |
3 ms |
348 KB |
Output is correct |
34 |
Correct |
226 ms |
333140 KB |
Output is correct |
35 |
Correct |
240 ms |
332880 KB |
Output is correct |
36 |
Correct |
232 ms |
333368 KB |
Output is correct |
37 |
Correct |
230 ms |
333144 KB |
Output is correct |
38 |
Correct |
190 ms |
333216 KB |
Output is correct |
39 |
Correct |
179 ms |
333044 KB |
Output is correct |
40 |
Correct |
43 ms |
348 KB |
Output is correct |
41 |
Correct |
114 ms |
348 KB |
Output is correct |
42 |
Correct |
42 ms |
552 KB |
Output is correct |
43 |
Correct |
45 ms |
556 KB |
Output is correct |
44 |
Runtime error |
7 ms |
604 KB |
Execution killed with signal 11 |
45 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 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 |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
600 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
92 ms |
504 KB |
Output is correct |
27 |
Correct |
104 ms |
344 KB |
Output is correct |
28 |
Correct |
100 ms |
348 KB |
Output is correct |
29 |
Correct |
90 ms |
504 KB |
Output is correct |
30 |
Correct |
41 ms |
344 KB |
Output is correct |
31 |
Correct |
103 ms |
348 KB |
Output is correct |
32 |
Correct |
90 ms |
348 KB |
Output is correct |
33 |
Correct |
33 ms |
344 KB |
Output is correct |
34 |
Correct |
53 ms |
584 KB |
Output is correct |
35 |
Correct |
3 ms |
344 KB |
Output is correct |
36 |
Correct |
3 ms |
348 KB |
Output is correct |
37 |
Correct |
42 ms |
348 KB |
Output is correct |
38 |
Correct |
42 ms |
344 KB |
Output is correct |
39 |
Correct |
26 ms |
344 KB |
Output is correct |
40 |
Correct |
0 ms |
348 KB |
Output is correct |
41 |
Correct |
0 ms |
348 KB |
Output is correct |
42 |
Correct |
1 ms |
344 KB |
Output is correct |
43 |
Correct |
0 ms |
348 KB |
Output is correct |
44 |
Correct |
0 ms |
348 KB |
Output is correct |
45 |
Correct |
0 ms |
348 KB |
Output is correct |
46 |
Correct |
0 ms |
348 KB |
Output is correct |
47 |
Correct |
0 ms |
344 KB |
Output is correct |
48 |
Correct |
0 ms |
348 KB |
Output is correct |
49 |
Correct |
0 ms |
348 KB |
Output is correct |
50 |
Correct |
246 ms |
333360 KB |
Output is correct |
51 |
Correct |
238 ms |
333404 KB |
Output is correct |
52 |
Correct |
260 ms |
333396 KB |
Output is correct |
53 |
Correct |
243 ms |
333328 KB |
Output is correct |
54 |
Correct |
253 ms |
333200 KB |
Output is correct |
55 |
Correct |
245 ms |
333188 KB |
Output is correct |
56 |
Correct |
0 ms |
348 KB |
Output is correct |
57 |
Correct |
0 ms |
348 KB |
Output is correct |
58 |
Correct |
1 ms |
600 KB |
Output is correct |
59 |
Correct |
1 ms |
348 KB |
Output is correct |
60 |
Correct |
22 ms |
476 KB |
Output is correct |
61 |
Correct |
248 ms |
333400 KB |
Output is correct |
62 |
Correct |
241 ms |
333396 KB |
Output is correct |
63 |
Correct |
240 ms |
333396 KB |
Output is correct |
64 |
Correct |
270 ms |
333328 KB |
Output is correct |
65 |
Correct |
247 ms |
333316 KB |
Output is correct |
66 |
Correct |
1 ms |
600 KB |
Output is correct |
67 |
Correct |
1 ms |
348 KB |
Output is correct |
68 |
Correct |
1 ms |
348 KB |
Output is correct |
69 |
Correct |
1 ms |
348 KB |
Output is correct |
70 |
Correct |
84 ms |
348 KB |
Output is correct |
71 |
Correct |
3 ms |
344 KB |
Output is correct |
72 |
Correct |
3 ms |
348 KB |
Output is correct |
73 |
Correct |
226 ms |
333140 KB |
Output is correct |
74 |
Correct |
240 ms |
332880 KB |
Output is correct |
75 |
Correct |
232 ms |
333368 KB |
Output is correct |
76 |
Correct |
230 ms |
333144 KB |
Output is correct |
77 |
Correct |
190 ms |
333216 KB |
Output is correct |
78 |
Correct |
179 ms |
333044 KB |
Output is correct |
79 |
Correct |
43 ms |
348 KB |
Output is correct |
80 |
Correct |
114 ms |
348 KB |
Output is correct |
81 |
Correct |
42 ms |
552 KB |
Output is correct |
82 |
Correct |
45 ms |
556 KB |
Output is correct |
83 |
Runtime error |
7 ms |
604 KB |
Execution killed with signal 11 |
84 |
Halted |
0 ms |
0 KB |
- |