#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define pb push_back
#define pow poww
const int M=5100;
const ll mod=998244353;
const ll inf=2e18;
const ll dx[]={1,-1,0,0};
const ll dy[]={0,0,1,-1};
ll pow(ll x,ll y){
ll res=1;
x%=mod;
while(y>0){
if(y%2==1){
res*=x,res%=mod;
}
x*=x,x%=mod;
y/=2;
}
return res;
}
ll nn,n,ma[M][M],a[M],b[M],c[M],rv1[M],rv2[M],rv3[M];
ll mp[301][301][301];
int main(){
ios_base::sync_with_stdio(0),cin.tie(0);
ll TC=1;
//cin>>TC;
while(TC--){
cin>>nn;
for(int i=0;i<nn;i++){
ll x,y,z;
cin>>x>>y>>z;
mp[x][y][z]=1;
}
for(int i=0;i<301;i++){
for(int j=0;j<301;j++){
for(int k=0;k<301;k++){
if(mp[i][j][k])
a[n++]=i,b[n-1]=j,c[n-1]=k;
}
}
}
for(int i=0;i<n;i++)
ma[a[i]][b[i]]=max(ma[a[i]][b[i]],c[i]);
for(int i=0;i<=300;i++){
for(int j=1;j<=300;j++)
ma[i][j]=max(ma[i][j-1],ma[i][j]);
}
for(int j=0;j<=300;j++){
for(int i=1;i<=300;i++)
ma[i][j]=max(ma[i][j],ma[i-1][j]);
}
ll ans=-1;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(i==j)
continue;
if(a[i]==a[j]||b[i]==b[j])
continue;
if(((a[i]>a[j])^(b[i]>b[j]))==0)
continue;
if(ma[max(a[i],a[j])-1][max(b[i],b[j])-1]<=max(c[i],c[j]))
continue;
ans=max(ans,max(a[i],a[j])+max(b[i],b[j])+ma[max(a[i],a[j])-1][max(b[i],b[j])-1]);
}
}
cout<<ans;
}
return 0;
}
/*
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
10584 KB |
Output is correct |
2 |
Correct |
19 ms |
10588 KB |
Output is correct |
3 |
Correct |
18 ms |
8580 KB |
Output is correct |
4 |
Correct |
20 ms |
8536 KB |
Output is correct |
5 |
Correct |
21 ms |
8528 KB |
Output is correct |
6 |
Correct |
19 ms |
8540 KB |
Output is correct |
7 |
Correct |
20 ms |
8540 KB |
Output is correct |
8 |
Correct |
21 ms |
8532 KB |
Output is correct |
9 |
Correct |
20 ms |
10584 KB |
Output is correct |
10 |
Correct |
20 ms |
10588 KB |
Output is correct |
11 |
Correct |
19 ms |
8540 KB |
Output is correct |
12 |
Correct |
17 ms |
8528 KB |
Output is correct |
13 |
Correct |
18 ms |
8540 KB |
Output is correct |
14 |
Runtime error |
5 ms |
528 KB |
Execution killed with signal 11 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
10584 KB |
Output is correct |
2 |
Correct |
19 ms |
10588 KB |
Output is correct |
3 |
Correct |
18 ms |
8580 KB |
Output is correct |
4 |
Correct |
20 ms |
8536 KB |
Output is correct |
5 |
Correct |
21 ms |
8528 KB |
Output is correct |
6 |
Correct |
19 ms |
8540 KB |
Output is correct |
7 |
Correct |
20 ms |
8540 KB |
Output is correct |
8 |
Correct |
21 ms |
8532 KB |
Output is correct |
9 |
Correct |
20 ms |
10584 KB |
Output is correct |
10 |
Correct |
20 ms |
10588 KB |
Output is correct |
11 |
Correct |
19 ms |
8540 KB |
Output is correct |
12 |
Correct |
17 ms |
8528 KB |
Output is correct |
13 |
Correct |
18 ms |
8540 KB |
Output is correct |
14 |
Runtime error |
5 ms |
528 KB |
Execution killed with signal 11 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
10588 KB |
Output is correct |
2 |
Correct |
21 ms |
10584 KB |
Output is correct |
3 |
Correct |
24 ms |
8540 KB |
Output is correct |
4 |
Correct |
18 ms |
8448 KB |
Output is correct |
5 |
Correct |
20 ms |
8564 KB |
Output is correct |
6 |
Correct |
19 ms |
8540 KB |
Output is correct |
7 |
Correct |
20 ms |
8520 KB |
Output is correct |
8 |
Correct |
19 ms |
8528 KB |
Output is correct |
9 |
Correct |
20 ms |
10584 KB |
Output is correct |
10 |
Correct |
19 ms |
10588 KB |
Output is correct |
11 |
Correct |
36 ms |
10624 KB |
Output is correct |
12 |
Correct |
41 ms |
11216 KB |
Output is correct |
13 |
Correct |
30 ms |
11344 KB |
Output is correct |
14 |
Correct |
34 ms |
11488 KB |
Output is correct |
15 |
Correct |
38 ms |
9296 KB |
Output is correct |
16 |
Correct |
34 ms |
9304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
10588 KB |
Output is correct |
2 |
Correct |
21 ms |
10584 KB |
Output is correct |
3 |
Correct |
24 ms |
8540 KB |
Output is correct |
4 |
Correct |
18 ms |
8448 KB |
Output is correct |
5 |
Correct |
20 ms |
8564 KB |
Output is correct |
6 |
Correct |
19 ms |
8540 KB |
Output is correct |
7 |
Correct |
20 ms |
8520 KB |
Output is correct |
8 |
Correct |
19 ms |
8528 KB |
Output is correct |
9 |
Correct |
20 ms |
10584 KB |
Output is correct |
10 |
Correct |
19 ms |
10588 KB |
Output is correct |
11 |
Correct |
36 ms |
10624 KB |
Output is correct |
12 |
Correct |
41 ms |
11216 KB |
Output is correct |
13 |
Correct |
30 ms |
11344 KB |
Output is correct |
14 |
Correct |
34 ms |
11488 KB |
Output is correct |
15 |
Correct |
38 ms |
9296 KB |
Output is correct |
16 |
Correct |
34 ms |
9304 KB |
Output is correct |
17 |
Correct |
18 ms |
8528 KB |
Output is correct |
18 |
Correct |
18 ms |
8536 KB |
Output is correct |
19 |
Correct |
18 ms |
8528 KB |
Output is correct |
20 |
Correct |
21 ms |
20828 KB |
Output is correct |
21 |
Correct |
27 ms |
20748 KB |
Output is correct |
22 |
Correct |
151 ms |
21968 KB |
Output is correct |
23 |
Correct |
43 ms |
21716 KB |
Output is correct |
24 |
Correct |
35 ms |
21584 KB |
Output is correct |
25 |
Correct |
39 ms |
21840 KB |
Output is correct |
26 |
Correct |
34 ms |
11468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
10588 KB |
Output is correct |
2 |
Correct |
21 ms |
10584 KB |
Output is correct |
3 |
Correct |
24 ms |
8540 KB |
Output is correct |
4 |
Correct |
18 ms |
8448 KB |
Output is correct |
5 |
Correct |
20 ms |
8564 KB |
Output is correct |
6 |
Correct |
19 ms |
8540 KB |
Output is correct |
7 |
Correct |
20 ms |
8520 KB |
Output is correct |
8 |
Correct |
19 ms |
8528 KB |
Output is correct |
9 |
Correct |
20 ms |
10584 KB |
Output is correct |
10 |
Correct |
19 ms |
10588 KB |
Output is correct |
11 |
Correct |
36 ms |
10624 KB |
Output is correct |
12 |
Correct |
41 ms |
11216 KB |
Output is correct |
13 |
Correct |
30 ms |
11344 KB |
Output is correct |
14 |
Correct |
34 ms |
11488 KB |
Output is correct |
15 |
Correct |
38 ms |
9296 KB |
Output is correct |
16 |
Correct |
34 ms |
9304 KB |
Output is correct |
17 |
Correct |
18 ms |
8528 KB |
Output is correct |
18 |
Correct |
18 ms |
8536 KB |
Output is correct |
19 |
Correct |
18 ms |
8528 KB |
Output is correct |
20 |
Correct |
21 ms |
20828 KB |
Output is correct |
21 |
Correct |
27 ms |
20748 KB |
Output is correct |
22 |
Correct |
151 ms |
21968 KB |
Output is correct |
23 |
Correct |
43 ms |
21716 KB |
Output is correct |
24 |
Correct |
35 ms |
21584 KB |
Output is correct |
25 |
Correct |
39 ms |
21840 KB |
Output is correct |
26 |
Correct |
34 ms |
11468 KB |
Output is correct |
27 |
Correct |
40 ms |
141540 KB |
Output is correct |
28 |
Correct |
26 ms |
72020 KB |
Output is correct |
29 |
Correct |
27 ms |
78168 KB |
Output is correct |
30 |
Correct |
27 ms |
78172 KB |
Output is correct |
31 |
Correct |
73 ms |
207708 KB |
Output is correct |
32 |
Correct |
69 ms |
195408 KB |
Output is correct |
33 |
Correct |
41 ms |
199412 KB |
Output is correct |
34 |
Execution timed out |
2062 ms |
217016 KB |
Time limit exceeded |
35 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
10588 KB |
Output is correct |
2 |
Correct |
21 ms |
10584 KB |
Output is correct |
3 |
Correct |
24 ms |
8540 KB |
Output is correct |
4 |
Correct |
18 ms |
8448 KB |
Output is correct |
5 |
Correct |
20 ms |
8564 KB |
Output is correct |
6 |
Correct |
19 ms |
8540 KB |
Output is correct |
7 |
Correct |
20 ms |
8520 KB |
Output is correct |
8 |
Correct |
19 ms |
8528 KB |
Output is correct |
9 |
Correct |
20 ms |
10584 KB |
Output is correct |
10 |
Correct |
19 ms |
10588 KB |
Output is correct |
11 |
Correct |
36 ms |
10624 KB |
Output is correct |
12 |
Correct |
41 ms |
11216 KB |
Output is correct |
13 |
Correct |
30 ms |
11344 KB |
Output is correct |
14 |
Correct |
34 ms |
11488 KB |
Output is correct |
15 |
Correct |
38 ms |
9296 KB |
Output is correct |
16 |
Correct |
34 ms |
9304 KB |
Output is correct |
17 |
Correct |
18 ms |
8528 KB |
Output is correct |
18 |
Correct |
18 ms |
8536 KB |
Output is correct |
19 |
Correct |
18 ms |
8528 KB |
Output is correct |
20 |
Correct |
21 ms |
20828 KB |
Output is correct |
21 |
Correct |
27 ms |
20748 KB |
Output is correct |
22 |
Correct |
151 ms |
21968 KB |
Output is correct |
23 |
Correct |
43 ms |
21716 KB |
Output is correct |
24 |
Correct |
35 ms |
21584 KB |
Output is correct |
25 |
Correct |
39 ms |
21840 KB |
Output is correct |
26 |
Correct |
34 ms |
11468 KB |
Output is correct |
27 |
Correct |
40 ms |
141540 KB |
Output is correct |
28 |
Correct |
26 ms |
72020 KB |
Output is correct |
29 |
Correct |
27 ms |
78168 KB |
Output is correct |
30 |
Correct |
27 ms |
78172 KB |
Output is correct |
31 |
Correct |
73 ms |
207708 KB |
Output is correct |
32 |
Correct |
69 ms |
195408 KB |
Output is correct |
33 |
Correct |
41 ms |
199412 KB |
Output is correct |
34 |
Execution timed out |
2062 ms |
217016 KB |
Time limit exceeded |
35 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
10584 KB |
Output is correct |
2 |
Correct |
19 ms |
10588 KB |
Output is correct |
3 |
Correct |
18 ms |
8580 KB |
Output is correct |
4 |
Correct |
20 ms |
8536 KB |
Output is correct |
5 |
Correct |
21 ms |
8528 KB |
Output is correct |
6 |
Correct |
19 ms |
8540 KB |
Output is correct |
7 |
Correct |
20 ms |
8540 KB |
Output is correct |
8 |
Correct |
21 ms |
8532 KB |
Output is correct |
9 |
Correct |
20 ms |
10584 KB |
Output is correct |
10 |
Correct |
20 ms |
10588 KB |
Output is correct |
11 |
Correct |
19 ms |
8540 KB |
Output is correct |
12 |
Correct |
17 ms |
8528 KB |
Output is correct |
13 |
Correct |
18 ms |
8540 KB |
Output is correct |
14 |
Runtime error |
5 ms |
528 KB |
Execution killed with signal 11 |
15 |
Halted |
0 ms |
0 KB |
- |