#include <bits/stdc++.h>
using namespace std;
constexpr int BASE = 1<<18;
struct cord{
int x, y, z;
};
cord INPUT[BASE];
int n;
int check(int i, int j, int k){
int ilei = 0;
int ilej = 0;
int ilek = 0;
int x = max({INPUT[i].x, INPUT[j].x, INPUT[k].x});
int y = max({INPUT[i].y, INPUT[j].y, INPUT[k].y});
int z = max({INPUT[i].z, INPUT[j].z, INPUT[k].z});
if(INPUT[i].x == x) ilei++;
if(INPUT[i].y == y) ilei++;
if(INPUT[i].z == z) ilei++;
if(INPUT[j].x == x) ilej++;
if(INPUT[j].y == y) ilej++;
if(INPUT[j].z == z) ilej++;
if(INPUT[k].x == x) ilek++;
if(INPUT[k].y == y) ilek++;
if(INPUT[k].z == z) ilek++;
if(ilei == ilej && ilej == ilek && ilej == 1) return x+y+z;
return -1;
}
int solve(){
int res = -1;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= i-1; j++){
for(int k = 1; k <= j-1; k++){
res = max(res, check(i, j, k));
}
}
}
return res;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i = 1; i <= n; i++)
cin >> INPUT[i].x >> INPUT[i].y >> INPUT[i].z;
cout << solve() << "\n";
}
# |
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 |
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 |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 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 |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
44 ms |
348 KB |
Output is correct |
15 |
Correct |
18 ms |
348 KB |
Output is correct |
16 |
Correct |
28 ms |
348 KB |
Output is correct |
17 |
Correct |
38 ms |
348 KB |
Output is correct |
18 |
Correct |
35 ms |
348 KB |
Output is correct |
19 |
Correct |
47 ms |
468 KB |
Output is correct |
20 |
Correct |
38 ms |
344 KB |
Output is correct |
21 |
Correct |
35 ms |
348 KB |
Output is correct |
22 |
Correct |
32 ms |
348 KB |
Output is correct |
23 |
Correct |
37 ms |
348 KB |
Output is correct |
24 |
Correct |
44 ms |
344 KB |
Output is correct |
25 |
Correct |
39 ms |
348 KB |
Output is correct |
# |
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 |
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 |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 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 |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
44 ms |
348 KB |
Output is correct |
15 |
Correct |
18 ms |
348 KB |
Output is correct |
16 |
Correct |
28 ms |
348 KB |
Output is correct |
17 |
Correct |
38 ms |
348 KB |
Output is correct |
18 |
Correct |
35 ms |
348 KB |
Output is correct |
19 |
Correct |
47 ms |
468 KB |
Output is correct |
20 |
Correct |
38 ms |
344 KB |
Output is correct |
21 |
Correct |
35 ms |
348 KB |
Output is correct |
22 |
Correct |
32 ms |
348 KB |
Output is correct |
23 |
Correct |
37 ms |
348 KB |
Output is correct |
24 |
Correct |
44 ms |
344 KB |
Output is correct |
25 |
Correct |
39 ms |
348 KB |
Output is correct |
26 |
Execution timed out |
2091 ms |
600 KB |
Time limit exceeded |
27 |
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 |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
464 KB |
Output is correct |
6 |
Correct |
0 ms |
344 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 |
Execution timed out |
2049 ms |
3420 KB |
Time limit exceeded |
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 |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
464 KB |
Output is correct |
6 |
Correct |
0 ms |
344 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 |
Execution timed out |
2049 ms |
3420 KB |
Time limit exceeded |
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 |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
464 KB |
Output is correct |
6 |
Correct |
0 ms |
344 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 |
Execution timed out |
2049 ms |
3420 KB |
Time limit exceeded |
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 |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
464 KB |
Output is correct |
6 |
Correct |
0 ms |
344 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 |
Execution timed out |
2049 ms |
3420 KB |
Time limit exceeded |
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 |
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 |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 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 |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
44 ms |
348 KB |
Output is correct |
15 |
Correct |
18 ms |
348 KB |
Output is correct |
16 |
Correct |
28 ms |
348 KB |
Output is correct |
17 |
Correct |
38 ms |
348 KB |
Output is correct |
18 |
Correct |
35 ms |
348 KB |
Output is correct |
19 |
Correct |
47 ms |
468 KB |
Output is correct |
20 |
Correct |
38 ms |
344 KB |
Output is correct |
21 |
Correct |
35 ms |
348 KB |
Output is correct |
22 |
Correct |
32 ms |
348 KB |
Output is correct |
23 |
Correct |
37 ms |
348 KB |
Output is correct |
24 |
Correct |
44 ms |
344 KB |
Output is correct |
25 |
Correct |
39 ms |
348 KB |
Output is correct |
26 |
Execution timed out |
2091 ms |
600 KB |
Time limit exceeded |
27 |
Halted |
0 ms |
0 KB |
- |