#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, A[150005], B[150005], C[150005];
vector <pi> v, v2, v3;
vector <pii> lmao;
void solve(){
cin >> n;
for(int i=1;i<=n;i++)cin >> A[i] >> B[i] >> C[i], v.push_back({A[i], i}), v2.push_back({B[i], i}), v3.push_back({C[i], i});
sort(v.begin(), v.end());
sort(v2.begin(), v2.end());
sort(v3.begin(), v3.end());
int x = n - 1, y = n - 1, z = n - 1;
while(x >= 0 && y >= 0 && z >= 0){
int a = v[x].se, b = v2[y].se, c = v3[z].se;
if((A[a] >= v[x].fi) + (B[a] >= v2[y].fi) + (C[a] >= v3[z].fi) >= 2)x--;
else if((A[b] >= v[x].fi) + (B[b] >= v2[y].fi) + (C[b] >= v3[z].fi) >= 2)y--;
else if((A[c] >= v[x].fi) + (B[c] >= v2[y].fi) + (C[c] >= v3[z].fi) >= 2)z--;
else {
cout << v[x].fi + v2[y].fi + v3[z].fi << '\n';
return;
}
}
cout << -1;
}
main(){
ios::sync_with_stdio(0);cin.tie(0);
int tc = 1;
//cin >> tc;
for(int tc1=1;tc1<=tc;tc1++){
// cout << "Case #" << tc1 << ": ";
solve();
}
}
Compilation message
team.cpp:37:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
37 | main(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 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 |
340 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 |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 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 |
340 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 |
3 ms |
744 KB |
Output is correct |
27 |
Correct |
3 ms |
724 KB |
Output is correct |
28 |
Correct |
3 ms |
724 KB |
Output is correct |
29 |
Correct |
4 ms |
728 KB |
Output is correct |
30 |
Correct |
2 ms |
596 KB |
Output is correct |
31 |
Correct |
2 ms |
724 KB |
Output is correct |
32 |
Correct |
2 ms |
724 KB |
Output is correct |
33 |
Correct |
3 ms |
724 KB |
Output is correct |
34 |
Correct |
2 ms |
724 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
1 ms |
340 KB |
Output is correct |
37 |
Correct |
2 ms |
724 KB |
Output is correct |
38 |
Correct |
2 ms |
724 KB |
Output is correct |
39 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
68 ms |
12600 KB |
Output is correct |
12 |
Correct |
44 ms |
7988 KB |
Output is correct |
13 |
Correct |
56 ms |
9868 KB |
Output is correct |
14 |
Correct |
72 ms |
12684 KB |
Output is correct |
15 |
Correct |
63 ms |
12628 KB |
Output is correct |
16 |
Correct |
42 ms |
12644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
68 ms |
12600 KB |
Output is correct |
12 |
Correct |
44 ms |
7988 KB |
Output is correct |
13 |
Correct |
56 ms |
9868 KB |
Output is correct |
14 |
Correct |
72 ms |
12684 KB |
Output is correct |
15 |
Correct |
63 ms |
12628 KB |
Output is correct |
16 |
Correct |
42 ms |
12644 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
0 ms |
332 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
596 KB |
Output is correct |
22 |
Correct |
77 ms |
12820 KB |
Output is correct |
23 |
Correct |
73 ms |
12648 KB |
Output is correct |
24 |
Correct |
58 ms |
8876 KB |
Output is correct |
25 |
Correct |
81 ms |
12916 KB |
Output is correct |
26 |
Correct |
78 ms |
12736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
68 ms |
12600 KB |
Output is correct |
12 |
Correct |
44 ms |
7988 KB |
Output is correct |
13 |
Correct |
56 ms |
9868 KB |
Output is correct |
14 |
Correct |
72 ms |
12684 KB |
Output is correct |
15 |
Correct |
63 ms |
12628 KB |
Output is correct |
16 |
Correct |
42 ms |
12644 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
0 ms |
332 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
596 KB |
Output is correct |
22 |
Correct |
77 ms |
12820 KB |
Output is correct |
23 |
Correct |
73 ms |
12648 KB |
Output is correct |
24 |
Correct |
58 ms |
8876 KB |
Output is correct |
25 |
Correct |
81 ms |
12916 KB |
Output is correct |
26 |
Correct |
78 ms |
12736 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
1 ms |
324 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
2 ms |
728 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
1 ms |
340 KB |
Output is correct |
34 |
Correct |
77 ms |
13280 KB |
Output is correct |
35 |
Correct |
74 ms |
13160 KB |
Output is correct |
36 |
Correct |
82 ms |
13300 KB |
Output is correct |
37 |
Correct |
81 ms |
13324 KB |
Output is correct |
38 |
Correct |
67 ms |
13216 KB |
Output is correct |
39 |
Correct |
41 ms |
7788 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
68 ms |
12600 KB |
Output is correct |
12 |
Correct |
44 ms |
7988 KB |
Output is correct |
13 |
Correct |
56 ms |
9868 KB |
Output is correct |
14 |
Correct |
72 ms |
12684 KB |
Output is correct |
15 |
Correct |
63 ms |
12628 KB |
Output is correct |
16 |
Correct |
42 ms |
12644 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
0 ms |
332 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
596 KB |
Output is correct |
22 |
Correct |
77 ms |
12820 KB |
Output is correct |
23 |
Correct |
73 ms |
12648 KB |
Output is correct |
24 |
Correct |
58 ms |
8876 KB |
Output is correct |
25 |
Correct |
81 ms |
12916 KB |
Output is correct |
26 |
Correct |
78 ms |
12736 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
1 ms |
324 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
2 ms |
728 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
1 ms |
340 KB |
Output is correct |
34 |
Correct |
77 ms |
13280 KB |
Output is correct |
35 |
Correct |
74 ms |
13160 KB |
Output is correct |
36 |
Correct |
82 ms |
13300 KB |
Output is correct |
37 |
Correct |
81 ms |
13324 KB |
Output is correct |
38 |
Correct |
67 ms |
13216 KB |
Output is correct |
39 |
Correct |
41 ms |
7788 KB |
Output is correct |
40 |
Correct |
2 ms |
596 KB |
Output is correct |
41 |
Correct |
2 ms |
724 KB |
Output is correct |
42 |
Correct |
2 ms |
724 KB |
Output is correct |
43 |
Correct |
3 ms |
724 KB |
Output is correct |
44 |
Correct |
84 ms |
13736 KB |
Output is correct |
45 |
Correct |
82 ms |
13664 KB |
Output is correct |
46 |
Correct |
106 ms |
13760 KB |
Output is correct |
47 |
Correct |
86 ms |
13704 KB |
Output is correct |
48 |
Correct |
72 ms |
13692 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 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 |
340 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 |
3 ms |
744 KB |
Output is correct |
27 |
Correct |
3 ms |
724 KB |
Output is correct |
28 |
Correct |
3 ms |
724 KB |
Output is correct |
29 |
Correct |
4 ms |
728 KB |
Output is correct |
30 |
Correct |
2 ms |
596 KB |
Output is correct |
31 |
Correct |
2 ms |
724 KB |
Output is correct |
32 |
Correct |
2 ms |
724 KB |
Output is correct |
33 |
Correct |
3 ms |
724 KB |
Output is correct |
34 |
Correct |
2 ms |
724 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
1 ms |
340 KB |
Output is correct |
37 |
Correct |
2 ms |
724 KB |
Output is correct |
38 |
Correct |
2 ms |
724 KB |
Output is correct |
39 |
Correct |
2 ms |
468 KB |
Output is correct |
40 |
Correct |
1 ms |
340 KB |
Output is correct |
41 |
Correct |
1 ms |
340 KB |
Output is correct |
42 |
Correct |
1 ms |
340 KB |
Output is correct |
43 |
Correct |
0 ms |
340 KB |
Output is correct |
44 |
Correct |
1 ms |
340 KB |
Output is correct |
45 |
Correct |
0 ms |
340 KB |
Output is correct |
46 |
Correct |
1 ms |
332 KB |
Output is correct |
47 |
Correct |
0 ms |
340 KB |
Output is correct |
48 |
Correct |
0 ms |
340 KB |
Output is correct |
49 |
Correct |
1 ms |
340 KB |
Output is correct |
50 |
Correct |
68 ms |
12600 KB |
Output is correct |
51 |
Correct |
44 ms |
7988 KB |
Output is correct |
52 |
Correct |
56 ms |
9868 KB |
Output is correct |
53 |
Correct |
72 ms |
12684 KB |
Output is correct |
54 |
Correct |
63 ms |
12628 KB |
Output is correct |
55 |
Correct |
42 ms |
12644 KB |
Output is correct |
56 |
Correct |
1 ms |
340 KB |
Output is correct |
57 |
Correct |
1 ms |
340 KB |
Output is correct |
58 |
Correct |
0 ms |
332 KB |
Output is correct |
59 |
Correct |
0 ms |
340 KB |
Output is correct |
60 |
Correct |
1 ms |
596 KB |
Output is correct |
61 |
Correct |
77 ms |
12820 KB |
Output is correct |
62 |
Correct |
73 ms |
12648 KB |
Output is correct |
63 |
Correct |
58 ms |
8876 KB |
Output is correct |
64 |
Correct |
81 ms |
12916 KB |
Output is correct |
65 |
Correct |
78 ms |
12736 KB |
Output is correct |
66 |
Correct |
1 ms |
332 KB |
Output is correct |
67 |
Correct |
1 ms |
324 KB |
Output is correct |
68 |
Correct |
1 ms |
340 KB |
Output is correct |
69 |
Correct |
1 ms |
340 KB |
Output is correct |
70 |
Correct |
2 ms |
728 KB |
Output is correct |
71 |
Correct |
1 ms |
340 KB |
Output is correct |
72 |
Correct |
1 ms |
340 KB |
Output is correct |
73 |
Correct |
77 ms |
13280 KB |
Output is correct |
74 |
Correct |
74 ms |
13160 KB |
Output is correct |
75 |
Correct |
82 ms |
13300 KB |
Output is correct |
76 |
Correct |
81 ms |
13324 KB |
Output is correct |
77 |
Correct |
67 ms |
13216 KB |
Output is correct |
78 |
Correct |
41 ms |
7788 KB |
Output is correct |
79 |
Correct |
2 ms |
596 KB |
Output is correct |
80 |
Correct |
2 ms |
724 KB |
Output is correct |
81 |
Correct |
2 ms |
724 KB |
Output is correct |
82 |
Correct |
3 ms |
724 KB |
Output is correct |
83 |
Correct |
84 ms |
13736 KB |
Output is correct |
84 |
Correct |
82 ms |
13664 KB |
Output is correct |
85 |
Correct |
106 ms |
13760 KB |
Output is correct |
86 |
Correct |
86 ms |
13704 KB |
Output is correct |
87 |
Correct |
72 ms |
13692 KB |
Output is correct |
88 |
Correct |
94 ms |
14764 KB |
Output is correct |
89 |
Correct |
108 ms |
14696 KB |
Output is correct |
90 |
Correct |
89 ms |
14688 KB |
Output is correct |
91 |
Correct |
106 ms |
14796 KB |
Output is correct |
92 |
Correct |
86 ms |
13600 KB |
Output is correct |
93 |
Correct |
89 ms |
13740 KB |
Output is correct |
94 |
Correct |
87 ms |
13736 KB |
Output is correct |
95 |
Correct |
86 ms |
14628 KB |
Output is correct |
96 |
Correct |
91 ms |
14688 KB |
Output is correct |
97 |
Correct |
85 ms |
14836 KB |
Output is correct |
98 |
Correct |
52 ms |
13780 KB |
Output is correct |
99 |
Correct |
82 ms |
13656 KB |
Output is correct |