#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int n;
int a[150005], b[150005], c[150005];
set<ii> A,B,C;
int main(){
scanf("%d",&n);
for (int i = 0; i < n; i++){
scanf("%d%d%d",&a[i],&b[i],&c[i]);
A.insert({a[i], i});
B.insert({b[i], i});
C.insert({c[i], i});
}
for (int i = 0; i < n; i++){
int aid = A.rbegin()->second;
int bid = B.rbegin()->second;
int cid = C.rbegin()->second;
int mxa = a[aid], mxb = b[bid], mxc = c[cid];
if (b[aid] == mxb || c[aid] == mxc){
A.erase({a[aid], aid});
B.erase({b[aid], aid});
C.erase({c[aid], aid});
}
else if (a[bid] == mxa || c[bid] == mxc){
A.erase({a[bid], bid});
B.erase({b[bid], bid});
C.erase({c[bid], bid});
}
else if (a[cid] == mxa || b[cid] == mxb){
A.erase({a[cid], cid});
B.erase({b[cid], cid});
C.erase({c[cid], cid});
}
else{
printf("%d",mxa+mxb+mxc);
return 0;
}
}
printf("-1");
}
Compilation message
team.cpp: In function 'int main()':
team.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
8 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
team.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
10 | scanf("%d%d%d",&a[i],&b[i],&c[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
316 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
316 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
320 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
316 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
316 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
320 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
5 ms |
980 KB |
Output is correct |
27 |
Correct |
6 ms |
956 KB |
Output is correct |
28 |
Correct |
5 ms |
1004 KB |
Output is correct |
29 |
Correct |
6 ms |
980 KB |
Output is correct |
30 |
Correct |
4 ms |
648 KB |
Output is correct |
31 |
Correct |
5 ms |
852 KB |
Output is correct |
32 |
Correct |
6 ms |
852 KB |
Output is correct |
33 |
Correct |
5 ms |
852 KB |
Output is correct |
34 |
Correct |
5 ms |
980 KB |
Output is correct |
35 |
Correct |
1 ms |
468 KB |
Output is correct |
36 |
Correct |
1 ms |
468 KB |
Output is correct |
37 |
Correct |
3 ms |
980 KB |
Output is correct |
38 |
Correct |
4 ms |
852 KB |
Output is correct |
39 |
Correct |
2 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
308 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
312 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
173 ms |
23464 KB |
Output is correct |
12 |
Correct |
147 ms |
15812 KB |
Output is correct |
13 |
Correct |
125 ms |
19232 KB |
Output is correct |
14 |
Correct |
228 ms |
23300 KB |
Output is correct |
15 |
Correct |
174 ms |
23284 KB |
Output is correct |
16 |
Correct |
172 ms |
23364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
308 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
312 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
173 ms |
23464 KB |
Output is correct |
12 |
Correct |
147 ms |
15812 KB |
Output is correct |
13 |
Correct |
125 ms |
19232 KB |
Output is correct |
14 |
Correct |
228 ms |
23300 KB |
Output is correct |
15 |
Correct |
174 ms |
23284 KB |
Output is correct |
16 |
Correct |
172 ms |
23364 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
596 KB |
Output is correct |
22 |
Correct |
206 ms |
23332 KB |
Output is correct |
23 |
Correct |
223 ms |
22760 KB |
Output is correct |
24 |
Correct |
197 ms |
17000 KB |
Output is correct |
25 |
Correct |
314 ms |
23356 KB |
Output is correct |
26 |
Correct |
189 ms |
23296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
308 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
312 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
173 ms |
23464 KB |
Output is correct |
12 |
Correct |
147 ms |
15812 KB |
Output is correct |
13 |
Correct |
125 ms |
19232 KB |
Output is correct |
14 |
Correct |
228 ms |
23300 KB |
Output is correct |
15 |
Correct |
174 ms |
23284 KB |
Output is correct |
16 |
Correct |
172 ms |
23364 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
596 KB |
Output is correct |
22 |
Correct |
206 ms |
23332 KB |
Output is correct |
23 |
Correct |
223 ms |
22760 KB |
Output is correct |
24 |
Correct |
197 ms |
17000 KB |
Output is correct |
25 |
Correct |
314 ms |
23356 KB |
Output is correct |
26 |
Correct |
189 ms |
23296 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
5 ms |
852 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
33 |
Correct |
1 ms |
468 KB |
Output is correct |
34 |
Correct |
299 ms |
22144 KB |
Output is correct |
35 |
Correct |
302 ms |
21160 KB |
Output is correct |
36 |
Correct |
367 ms |
23360 KB |
Output is correct |
37 |
Correct |
393 ms |
23084 KB |
Output is correct |
38 |
Correct |
231 ms |
22732 KB |
Output is correct |
39 |
Correct |
111 ms |
14088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
308 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
312 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
173 ms |
23464 KB |
Output is correct |
12 |
Correct |
147 ms |
15812 KB |
Output is correct |
13 |
Correct |
125 ms |
19232 KB |
Output is correct |
14 |
Correct |
228 ms |
23300 KB |
Output is correct |
15 |
Correct |
174 ms |
23284 KB |
Output is correct |
16 |
Correct |
172 ms |
23364 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
596 KB |
Output is correct |
22 |
Correct |
206 ms |
23332 KB |
Output is correct |
23 |
Correct |
223 ms |
22760 KB |
Output is correct |
24 |
Correct |
197 ms |
17000 KB |
Output is correct |
25 |
Correct |
314 ms |
23356 KB |
Output is correct |
26 |
Correct |
189 ms |
23296 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
5 ms |
852 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
33 |
Correct |
1 ms |
468 KB |
Output is correct |
34 |
Correct |
299 ms |
22144 KB |
Output is correct |
35 |
Correct |
302 ms |
21160 KB |
Output is correct |
36 |
Correct |
367 ms |
23360 KB |
Output is correct |
37 |
Correct |
393 ms |
23084 KB |
Output is correct |
38 |
Correct |
231 ms |
22732 KB |
Output is correct |
39 |
Correct |
111 ms |
14088 KB |
Output is correct |
40 |
Correct |
4 ms |
724 KB |
Output is correct |
41 |
Correct |
4 ms |
980 KB |
Output is correct |
42 |
Correct |
3 ms |
824 KB |
Output is correct |
43 |
Correct |
4 ms |
968 KB |
Output is correct |
44 |
Correct |
357 ms |
23220 KB |
Output is correct |
45 |
Correct |
501 ms |
23304 KB |
Output is correct |
46 |
Correct |
467 ms |
23396 KB |
Output is correct |
47 |
Correct |
484 ms |
23428 KB |
Output is correct |
48 |
Correct |
294 ms |
23552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
316 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
316 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
320 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
5 ms |
980 KB |
Output is correct |
27 |
Correct |
6 ms |
956 KB |
Output is correct |
28 |
Correct |
5 ms |
1004 KB |
Output is correct |
29 |
Correct |
6 ms |
980 KB |
Output is correct |
30 |
Correct |
4 ms |
648 KB |
Output is correct |
31 |
Correct |
5 ms |
852 KB |
Output is correct |
32 |
Correct |
6 ms |
852 KB |
Output is correct |
33 |
Correct |
5 ms |
852 KB |
Output is correct |
34 |
Correct |
5 ms |
980 KB |
Output is correct |
35 |
Correct |
1 ms |
468 KB |
Output is correct |
36 |
Correct |
1 ms |
468 KB |
Output is correct |
37 |
Correct |
3 ms |
980 KB |
Output is correct |
38 |
Correct |
4 ms |
852 KB |
Output is correct |
39 |
Correct |
2 ms |
596 KB |
Output is correct |
40 |
Correct |
1 ms |
308 KB |
Output is correct |
41 |
Correct |
0 ms |
212 KB |
Output is correct |
42 |
Correct |
1 ms |
212 KB |
Output is correct |
43 |
Correct |
0 ms |
212 KB |
Output is correct |
44 |
Correct |
1 ms |
212 KB |
Output is correct |
45 |
Correct |
1 ms |
212 KB |
Output is correct |
46 |
Correct |
1 ms |
312 KB |
Output is correct |
47 |
Correct |
1 ms |
212 KB |
Output is correct |
48 |
Correct |
1 ms |
212 KB |
Output is correct |
49 |
Correct |
0 ms |
212 KB |
Output is correct |
50 |
Correct |
173 ms |
23464 KB |
Output is correct |
51 |
Correct |
147 ms |
15812 KB |
Output is correct |
52 |
Correct |
125 ms |
19232 KB |
Output is correct |
53 |
Correct |
228 ms |
23300 KB |
Output is correct |
54 |
Correct |
174 ms |
23284 KB |
Output is correct |
55 |
Correct |
172 ms |
23364 KB |
Output is correct |
56 |
Correct |
1 ms |
212 KB |
Output is correct |
57 |
Correct |
1 ms |
212 KB |
Output is correct |
58 |
Correct |
1 ms |
212 KB |
Output is correct |
59 |
Correct |
1 ms |
340 KB |
Output is correct |
60 |
Correct |
2 ms |
596 KB |
Output is correct |
61 |
Correct |
206 ms |
23332 KB |
Output is correct |
62 |
Correct |
223 ms |
22760 KB |
Output is correct |
63 |
Correct |
197 ms |
17000 KB |
Output is correct |
64 |
Correct |
314 ms |
23356 KB |
Output is correct |
65 |
Correct |
189 ms |
23296 KB |
Output is correct |
66 |
Correct |
1 ms |
340 KB |
Output is correct |
67 |
Correct |
1 ms |
340 KB |
Output is correct |
68 |
Correct |
1 ms |
340 KB |
Output is correct |
69 |
Correct |
1 ms |
340 KB |
Output is correct |
70 |
Correct |
5 ms |
852 KB |
Output is correct |
71 |
Correct |
1 ms |
468 KB |
Output is correct |
72 |
Correct |
1 ms |
468 KB |
Output is correct |
73 |
Correct |
299 ms |
22144 KB |
Output is correct |
74 |
Correct |
302 ms |
21160 KB |
Output is correct |
75 |
Correct |
367 ms |
23360 KB |
Output is correct |
76 |
Correct |
393 ms |
23084 KB |
Output is correct |
77 |
Correct |
231 ms |
22732 KB |
Output is correct |
78 |
Correct |
111 ms |
14088 KB |
Output is correct |
79 |
Correct |
4 ms |
724 KB |
Output is correct |
80 |
Correct |
4 ms |
980 KB |
Output is correct |
81 |
Correct |
3 ms |
824 KB |
Output is correct |
82 |
Correct |
4 ms |
968 KB |
Output is correct |
83 |
Correct |
357 ms |
23220 KB |
Output is correct |
84 |
Correct |
501 ms |
23304 KB |
Output is correct |
85 |
Correct |
467 ms |
23396 KB |
Output is correct |
86 |
Correct |
484 ms |
23428 KB |
Output is correct |
87 |
Correct |
294 ms |
23552 KB |
Output is correct |
88 |
Correct |
374 ms |
23568 KB |
Output is correct |
89 |
Correct |
445 ms |
23624 KB |
Output is correct |
90 |
Correct |
374 ms |
23708 KB |
Output is correct |
91 |
Correct |
460 ms |
23468 KB |
Output is correct |
92 |
Correct |
434 ms |
23500 KB |
Output is correct |
93 |
Correct |
454 ms |
23472 KB |
Output is correct |
94 |
Correct |
462 ms |
23564 KB |
Output is correct |
95 |
Correct |
288 ms |
23644 KB |
Output is correct |
96 |
Correct |
253 ms |
23664 KB |
Output is correct |
97 |
Correct |
177 ms |
23712 KB |
Output is correct |
98 |
Correct |
148 ms |
23512 KB |
Output is correct |
99 |
Correct |
175 ms |
23556 KB |
Output is correct |