#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<array<int, 3>> a(n);
for (int i = 0; i < n; i++) {
int x, y, z;
cin >> x >> y >> z;
a[i] = {x, y, z};
}
auto get = [&](int i, int j, int k) -> int {
array<int, 3> mx;
mx[0] = max({a[i][0], a[j][0], a[k][0]});
mx[1] = max({a[i][1], a[j][1], a[k][1]});
mx[2] = max({a[i][2], a[j][2], a[k][2]});
int cnti = 0, cntj = 0, cntk = 0;
for (int t = 0; t < 3; t++) {
cnti += (mx[t] == a[i][t]);
cntj += (mx[t] == a[j][t]);
cntk += (mx[t] == a[k][t]);
}
if (array<int, 3>{cnti, cntj, cntk} != array<int, 3>{1, 1, 1}) return -1;
return mx[0] + mx[1] + mx[2];
};
int res = -1;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
for (int k = j + 1; k < n; k++) {
res = max(res, get(i, j, k));
}
}
}
cout << res << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
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 |
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 |
41 ms |
440 KB |
Output is correct |
15 |
Correct |
23 ms |
348 KB |
Output is correct |
16 |
Correct |
36 ms |
348 KB |
Output is correct |
17 |
Correct |
47 ms |
348 KB |
Output is correct |
18 |
Correct |
45 ms |
348 KB |
Output is correct |
19 |
Correct |
55 ms |
604 KB |
Output is correct |
20 |
Correct |
47 ms |
348 KB |
Output is correct |
21 |
Correct |
44 ms |
348 KB |
Output is correct |
22 |
Correct |
43 ms |
348 KB |
Output is correct |
23 |
Correct |
47 ms |
600 KB |
Output is correct |
24 |
Correct |
46 ms |
344 KB |
Output is correct |
25 |
Correct |
47 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
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 |
41 ms |
440 KB |
Output is correct |
15 |
Correct |
23 ms |
348 KB |
Output is correct |
16 |
Correct |
36 ms |
348 KB |
Output is correct |
17 |
Correct |
47 ms |
348 KB |
Output is correct |
18 |
Correct |
45 ms |
348 KB |
Output is correct |
19 |
Correct |
55 ms |
604 KB |
Output is correct |
20 |
Correct |
47 ms |
348 KB |
Output is correct |
21 |
Correct |
44 ms |
348 KB |
Output is correct |
22 |
Correct |
43 ms |
348 KB |
Output is correct |
23 |
Correct |
47 ms |
600 KB |
Output is correct |
24 |
Correct |
46 ms |
344 KB |
Output is correct |
25 |
Correct |
47 ms |
348 KB |
Output is correct |
26 |
Execution timed out |
2052 ms |
604 KB |
Time limit exceeded |
27 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 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 |
2021 ms |
2392 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 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 |
2021 ms |
2392 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 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 |
2021 ms |
2392 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 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 |
2021 ms |
2392 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
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 |
41 ms |
440 KB |
Output is correct |
15 |
Correct |
23 ms |
348 KB |
Output is correct |
16 |
Correct |
36 ms |
348 KB |
Output is correct |
17 |
Correct |
47 ms |
348 KB |
Output is correct |
18 |
Correct |
45 ms |
348 KB |
Output is correct |
19 |
Correct |
55 ms |
604 KB |
Output is correct |
20 |
Correct |
47 ms |
348 KB |
Output is correct |
21 |
Correct |
44 ms |
348 KB |
Output is correct |
22 |
Correct |
43 ms |
348 KB |
Output is correct |
23 |
Correct |
47 ms |
600 KB |
Output is correct |
24 |
Correct |
46 ms |
344 KB |
Output is correct |
25 |
Correct |
47 ms |
348 KB |
Output is correct |
26 |
Execution timed out |
2052 ms |
604 KB |
Time limit exceeded |
27 |
Halted |
0 ms |
0 KB |
- |