#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <cstring>
#warning That's the baby, that's not my baby
typedef long long ll;
int dumb(int n, std::vector<int> a, std::vector<int> b, std::vector<int> c) {
int answer = -1;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
for (int k = 0; k < n; k++) {
if (a[i] > a[j] && a[i] > a[k] && b[j] > b[i] && b[j] > b[k] && c[k] > c[i] && c[k] > c[j]) {
answer = std::max(answer, a[i] + b[j] + c[k]);
}
}
}
}
return answer;
}
int smart(int n, std::vector<int> a, std::vector<int> b, std::vector<int> c) {
if (n < 3) {
return -1;
}
int answer = 0;
int maxA = *std::max_element(a.begin(), a.end());
int maxB = *std::max_element(b.begin(), b.end());
int maxC = *std::max_element(c.begin(), c.end());
std::vector<int> A, B, C;
for (int i = 0; i < n; i++) {
int cnt = (a[i] == maxA) + (b[i] == maxB) + (c[i] == maxC);
if (cnt <= 1) {
A.push_back(a[i]);
B.push_back(b[i]);
C.push_back(c[i]);
}
}
if ((int) A.size() == n) {
return maxA + maxB + maxC;
} else {
return smart((int) A.size(), A, B, C);
}
}
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(0);
int n;
std::cin >> n;
std::vector<int> a(n), b(n), c(n);
for (int i = 0; i < n; i++) {
std::cin >> a[i] >> b[i] >> c[i];
}
std::cout << smart(n, a, b, c);
return 0;
}
Compilation message
team.cpp:6:2: warning: #warning That's the baby, that's not my baby [-Wcpp]
6 | #warning That's the baby, that's not my baby
| ^~~~~~~
team.cpp: In function 'int smart(int, std::vector<int>, std::vector<int>, std::vector<int>)':
team.cpp:28:7: warning: unused variable 'answer' [-Wunused-variable]
28 | int answer = 0;
| ^~~~~~
# |
결과 |
실행 시간 |
메모리 |
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 |
1 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 |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
720 KB |
Output is correct |
16 |
Correct |
0 ms |
860 KB |
Output is correct |
17 |
Correct |
1 ms |
1116 KB |
Output is correct |
18 |
Correct |
1 ms |
604 KB |
Output is correct |
19 |
Correct |
0 ms |
604 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
1652 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
860 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 |
1 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 |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
720 KB |
Output is correct |
16 |
Correct |
0 ms |
860 KB |
Output is correct |
17 |
Correct |
1 ms |
1116 KB |
Output is correct |
18 |
Correct |
1 ms |
604 KB |
Output is correct |
19 |
Correct |
0 ms |
604 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
1652 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
860 KB |
Output is correct |
26 |
Correct |
1 ms |
604 KB |
Output is correct |
27 |
Correct |
41 ms |
49568 KB |
Output is correct |
28 |
Correct |
76 ms |
90452 KB |
Output is correct |
29 |
Correct |
78 ms |
132688 KB |
Output is correct |
30 |
Correct |
54 ms |
55892 KB |
Output is correct |
31 |
Correct |
40 ms |
37972 KB |
Output is correct |
32 |
Correct |
11 ms |
16988 KB |
Output is correct |
33 |
Correct |
1 ms |
604 KB |
Output is correct |
34 |
Correct |
127 ms |
215800 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
3 ms |
5264 KB |
Output is correct |
37 |
Correct |
1 ms |
604 KB |
Output is correct |
38 |
Correct |
51 ms |
87360 KB |
Output is correct |
39 |
Correct |
1 ms |
604 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 |
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 |
20 ms |
10016 KB |
Output is correct |
12 |
Correct |
20 ms |
12872 KB |
Output is correct |
13 |
Correct |
31 ms |
27488 KB |
Output is correct |
14 |
Correct |
29 ms |
14544 KB |
Output is correct |
15 |
Correct |
16 ms |
4700 KB |
Output is correct |
16 |
Correct |
16 ms |
4700 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 |
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 |
20 ms |
10016 KB |
Output is correct |
12 |
Correct |
20 ms |
12872 KB |
Output is correct |
13 |
Correct |
31 ms |
27488 KB |
Output is correct |
14 |
Correct |
29 ms |
14544 KB |
Output is correct |
15 |
Correct |
16 ms |
4700 KB |
Output is correct |
16 |
Correct |
16 ms |
4700 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
604 KB |
Output is correct |
22 |
Correct |
24 ms |
11704 KB |
Output is correct |
23 |
Correct |
93 ms |
109112 KB |
Output is correct |
24 |
Correct |
59 ms |
60212 KB |
Output is correct |
25 |
Correct |
70 ms |
71612 KB |
Output is correct |
26 |
Correct |
18 ms |
4956 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 |
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 |
20 ms |
10016 KB |
Output is correct |
12 |
Correct |
20 ms |
12872 KB |
Output is correct |
13 |
Correct |
31 ms |
27488 KB |
Output is correct |
14 |
Correct |
29 ms |
14544 KB |
Output is correct |
15 |
Correct |
16 ms |
4700 KB |
Output is correct |
16 |
Correct |
16 ms |
4700 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
604 KB |
Output is correct |
22 |
Correct |
24 ms |
11704 KB |
Output is correct |
23 |
Correct |
93 ms |
109112 KB |
Output is correct |
24 |
Correct |
59 ms |
60212 KB |
Output is correct |
25 |
Correct |
70 ms |
71612 KB |
Output is correct |
26 |
Correct |
18 ms |
4956 KB |
Output is correct |
27 |
Correct |
0 ms |
604 KB |
Output is correct |
28 |
Correct |
1 ms |
604 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
860 KB |
Output is correct |
31 |
Correct |
11 ms |
16824 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
3 ms |
5212 KB |
Output is correct |
34 |
Correct |
27 ms |
11700 KB |
Output is correct |
35 |
Correct |
640 ms |
919596 KB |
Output is correct |
36 |
Runtime error |
846 ms |
1048576 KB |
Execution killed with signal 9 |
37 |
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 |
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 |
20 ms |
10016 KB |
Output is correct |
12 |
Correct |
20 ms |
12872 KB |
Output is correct |
13 |
Correct |
31 ms |
27488 KB |
Output is correct |
14 |
Correct |
29 ms |
14544 KB |
Output is correct |
15 |
Correct |
16 ms |
4700 KB |
Output is correct |
16 |
Correct |
16 ms |
4700 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
604 KB |
Output is correct |
22 |
Correct |
24 ms |
11704 KB |
Output is correct |
23 |
Correct |
93 ms |
109112 KB |
Output is correct |
24 |
Correct |
59 ms |
60212 KB |
Output is correct |
25 |
Correct |
70 ms |
71612 KB |
Output is correct |
26 |
Correct |
18 ms |
4956 KB |
Output is correct |
27 |
Correct |
0 ms |
604 KB |
Output is correct |
28 |
Correct |
1 ms |
604 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
860 KB |
Output is correct |
31 |
Correct |
11 ms |
16824 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
3 ms |
5212 KB |
Output is correct |
34 |
Correct |
27 ms |
11700 KB |
Output is correct |
35 |
Correct |
640 ms |
919596 KB |
Output is correct |
36 |
Runtime error |
846 ms |
1048576 KB |
Execution killed with signal 9 |
37 |
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 |
1 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 |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
720 KB |
Output is correct |
16 |
Correct |
0 ms |
860 KB |
Output is correct |
17 |
Correct |
1 ms |
1116 KB |
Output is correct |
18 |
Correct |
1 ms |
604 KB |
Output is correct |
19 |
Correct |
0 ms |
604 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
1652 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
860 KB |
Output is correct |
26 |
Correct |
1 ms |
604 KB |
Output is correct |
27 |
Correct |
41 ms |
49568 KB |
Output is correct |
28 |
Correct |
76 ms |
90452 KB |
Output is correct |
29 |
Correct |
78 ms |
132688 KB |
Output is correct |
30 |
Correct |
54 ms |
55892 KB |
Output is correct |
31 |
Correct |
40 ms |
37972 KB |
Output is correct |
32 |
Correct |
11 ms |
16988 KB |
Output is correct |
33 |
Correct |
1 ms |
604 KB |
Output is correct |
34 |
Correct |
127 ms |
215800 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
3 ms |
5264 KB |
Output is correct |
37 |
Correct |
1 ms |
604 KB |
Output is correct |
38 |
Correct |
51 ms |
87360 KB |
Output is correct |
39 |
Correct |
1 ms |
604 KB |
Output is correct |
40 |
Correct |
0 ms |
348 KB |
Output is correct |
41 |
Correct |
0 ms |
348 KB |
Output is correct |
42 |
Correct |
0 ms |
348 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 |
348 KB |
Output is correct |
48 |
Correct |
0 ms |
348 KB |
Output is correct |
49 |
Correct |
0 ms |
348 KB |
Output is correct |
50 |
Correct |
20 ms |
10016 KB |
Output is correct |
51 |
Correct |
20 ms |
12872 KB |
Output is correct |
52 |
Correct |
31 ms |
27488 KB |
Output is correct |
53 |
Correct |
29 ms |
14544 KB |
Output is correct |
54 |
Correct |
16 ms |
4700 KB |
Output is correct |
55 |
Correct |
16 ms |
4700 KB |
Output is correct |
56 |
Correct |
0 ms |
348 KB |
Output is correct |
57 |
Correct |
1 ms |
348 KB |
Output is correct |
58 |
Correct |
0 ms |
348 KB |
Output is correct |
59 |
Correct |
0 ms |
348 KB |
Output is correct |
60 |
Correct |
1 ms |
604 KB |
Output is correct |
61 |
Correct |
24 ms |
11704 KB |
Output is correct |
62 |
Correct |
93 ms |
109112 KB |
Output is correct |
63 |
Correct |
59 ms |
60212 KB |
Output is correct |
64 |
Correct |
70 ms |
71612 KB |
Output is correct |
65 |
Correct |
18 ms |
4956 KB |
Output is correct |
66 |
Correct |
0 ms |
604 KB |
Output is correct |
67 |
Correct |
1 ms |
604 KB |
Output is correct |
68 |
Correct |
0 ms |
348 KB |
Output is correct |
69 |
Correct |
1 ms |
860 KB |
Output is correct |
70 |
Correct |
11 ms |
16824 KB |
Output is correct |
71 |
Correct |
1 ms |
348 KB |
Output is correct |
72 |
Correct |
3 ms |
5212 KB |
Output is correct |
73 |
Correct |
27 ms |
11700 KB |
Output is correct |
74 |
Correct |
640 ms |
919596 KB |
Output is correct |
75 |
Runtime error |
846 ms |
1048576 KB |
Execution killed with signal 9 |
76 |
Halted |
0 ms |
0 KB |
- |