#include <bits/stdc++.h>
#define int long long
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
using namespace std;
signed main(){
int n;
cin>>n;
vector <vector <int> > a;
for(int i=0;i<n;i++){
int x,y,z;
cin>>x>>y>>z;
a.pb({x,y,z});
}
if(n<=300){
int res=0;
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
for(int k=j+1;k<n;k++){
bool flag=true;
int ans=0;
set <int> st;
for(int t=0;t<3;t++){
int mx=0,cnt=0,x=-1;
mx=max(a[i][t],mx);
mx=max(a[j][t],mx);
mx=max(a[k][t],mx);
if(mx==a[i][t]){
cnt++;x=i;
}
if(mx==a[j][t]){
cnt++;x=j;
}
if(mx==a[k][t]){
cnt++;x=k;
}
if(cnt==1){
ans+=mx;
st.insert(x);
}
else flag=false;
}
if(flag && st.size()==3)res=max(res,ans);
}
}
}
if(res==0)res=-1;
cout<<res<<"\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
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 |
348 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 |
289 ms |
436 KB |
Output is correct |
15 |
Correct |
114 ms |
424 KB |
Output is correct |
16 |
Correct |
180 ms |
348 KB |
Output is correct |
17 |
Correct |
215 ms |
436 KB |
Output is correct |
18 |
Correct |
229 ms |
592 KB |
Output is correct |
19 |
Correct |
264 ms |
348 KB |
Output is correct |
20 |
Correct |
244 ms |
344 KB |
Output is correct |
21 |
Correct |
95 ms |
440 KB |
Output is correct |
22 |
Correct |
118 ms |
440 KB |
Output is correct |
23 |
Correct |
34 ms |
348 KB |
Output is correct |
24 |
Correct |
127 ms |
436 KB |
Output is correct |
25 |
Correct |
128 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
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 |
348 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 |
289 ms |
436 KB |
Output is correct |
15 |
Correct |
114 ms |
424 KB |
Output is correct |
16 |
Correct |
180 ms |
348 KB |
Output is correct |
17 |
Correct |
215 ms |
436 KB |
Output is correct |
18 |
Correct |
229 ms |
592 KB |
Output is correct |
19 |
Correct |
264 ms |
348 KB |
Output is correct |
20 |
Correct |
244 ms |
344 KB |
Output is correct |
21 |
Correct |
95 ms |
440 KB |
Output is correct |
22 |
Correct |
118 ms |
440 KB |
Output is correct |
23 |
Correct |
34 ms |
348 KB |
Output is correct |
24 |
Correct |
127 ms |
436 KB |
Output is correct |
25 |
Correct |
128 ms |
344 KB |
Output is correct |
26 |
Incorrect |
5 ms |
604 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
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 |
348 KB |
Output is correct |
11 |
Incorrect |
56 ms |
11616 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
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 |
348 KB |
Output is correct |
11 |
Incorrect |
56 ms |
11616 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
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 |
348 KB |
Output is correct |
11 |
Incorrect |
56 ms |
11616 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
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 |
348 KB |
Output is correct |
11 |
Incorrect |
56 ms |
11616 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
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 |
348 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 |
289 ms |
436 KB |
Output is correct |
15 |
Correct |
114 ms |
424 KB |
Output is correct |
16 |
Correct |
180 ms |
348 KB |
Output is correct |
17 |
Correct |
215 ms |
436 KB |
Output is correct |
18 |
Correct |
229 ms |
592 KB |
Output is correct |
19 |
Correct |
264 ms |
348 KB |
Output is correct |
20 |
Correct |
244 ms |
344 KB |
Output is correct |
21 |
Correct |
95 ms |
440 KB |
Output is correct |
22 |
Correct |
118 ms |
440 KB |
Output is correct |
23 |
Correct |
34 ms |
348 KB |
Output is correct |
24 |
Correct |
127 ms |
436 KB |
Output is correct |
25 |
Correct |
128 ms |
344 KB |
Output is correct |
26 |
Incorrect |
5 ms |
604 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |