#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define ordered_multiset tree<type1, null_type, less_equal<type1>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
using namespace __gnu_pbds;
const int mod = 998244353;
const double PI = acos(-1.0);
const double epsilon = 1e-6;
const int N = 1.5e5+5;
int n;
vector<int> a(N),b(N),c(N);
int mp[6][6][6];
void solve3(){
int ans = -1;
for(int i = 0; i < n; i++){
mp[a[i]][b[i]][c[i]]++;
}
for(int x = 1; x <= 5; x++){
for(int y = 1; y <= 5; y++){
for(int z = 1; z <= 5; z++){
for(int x1 = 1; x1 <= 5; x1++){
for(int y1 = 1; y1 <= 5; y1++){
for(int z1 = 1; z1 <= 5; z1++){
for(int x2 = 1; x2 <= 5; x2++){
for(int y2 = 1; y2 <= 5; y2++){
for(int z2 = 1; z2 <= 5; z2++){
if((x == x1 && y == y1 && z == z1) || (x2 == x1 && y2 == y1 && z2 == z1) || (x == x2 && y == y2 && z == z2)) continue;
if(!(x > x1 && x > x2 && y1 > y && y1 > y2 && z2 > z && z2 > z1)) continue;
if(mp[x][y][z] && mp[x1][y1][z1] && mp[x2][y2][z2]){
ans = max(ans, x + y1 + z2);
}
}
}
}
}
}
}
}
}
}
cout << ans;
}
void solve(){
cin >> n;
for(int i = 0; i < n; i++){
cin >> a[i] >> b[i] >> c[i];
}
if(n > 300){
solve3();
return;
}
int ans = -1;
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
for(int k = 0; k < n; k++){
if(i == j || i == k || j == k) continue;
if(a[i] > a[j] && a[i] > a[k] &&
b[j] > b[i] && b[j] > b[k] &&
c[k] > c[j] && c[k] > c[i]
) ans = max(ans, a[i] + b[j] + c[k]);
}
}
}
cout << ans;
}
main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int tt = 1;
//cin >> tt;
while (tt--) {
solve();
}
}
Compilation message
team.cpp:84:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
84 | main(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3928 KB |
Output is correct |
2 |
Correct |
2 ms |
3932 KB |
Output is correct |
3 |
Correct |
2 ms |
3992 KB |
Output is correct |
4 |
Correct |
2 ms |
3932 KB |
Output is correct |
5 |
Correct |
2 ms |
3932 KB |
Output is correct |
6 |
Correct |
2 ms |
3932 KB |
Output is correct |
7 |
Correct |
1 ms |
3932 KB |
Output is correct |
8 |
Correct |
2 ms |
3932 KB |
Output is correct |
9 |
Correct |
1 ms |
3932 KB |
Output is correct |
10 |
Correct |
1 ms |
3816 KB |
Output is correct |
11 |
Correct |
2 ms |
3928 KB |
Output is correct |
12 |
Correct |
2 ms |
3932 KB |
Output is correct |
13 |
Correct |
1 ms |
3932 KB |
Output is correct |
14 |
Correct |
68 ms |
3980 KB |
Output is correct |
15 |
Correct |
27 ms |
3932 KB |
Output is correct |
16 |
Correct |
54 ms |
3932 KB |
Output is correct |
17 |
Correct |
55 ms |
3932 KB |
Output is correct |
18 |
Correct |
54 ms |
3928 KB |
Output is correct |
19 |
Correct |
65 ms |
3932 KB |
Output is correct |
20 |
Correct |
58 ms |
3972 KB |
Output is correct |
21 |
Correct |
32 ms |
3932 KB |
Output is correct |
22 |
Correct |
35 ms |
3932 KB |
Output is correct |
23 |
Correct |
28 ms |
3928 KB |
Output is correct |
24 |
Correct |
40 ms |
3928 KB |
Output is correct |
25 |
Correct |
36 ms |
3932 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3928 KB |
Output is correct |
2 |
Correct |
2 ms |
3932 KB |
Output is correct |
3 |
Correct |
2 ms |
3992 KB |
Output is correct |
4 |
Correct |
2 ms |
3932 KB |
Output is correct |
5 |
Correct |
2 ms |
3932 KB |
Output is correct |
6 |
Correct |
2 ms |
3932 KB |
Output is correct |
7 |
Correct |
1 ms |
3932 KB |
Output is correct |
8 |
Correct |
2 ms |
3932 KB |
Output is correct |
9 |
Correct |
1 ms |
3932 KB |
Output is correct |
10 |
Correct |
1 ms |
3816 KB |
Output is correct |
11 |
Correct |
2 ms |
3928 KB |
Output is correct |
12 |
Correct |
2 ms |
3932 KB |
Output is correct |
13 |
Correct |
1 ms |
3932 KB |
Output is correct |
14 |
Correct |
68 ms |
3980 KB |
Output is correct |
15 |
Correct |
27 ms |
3932 KB |
Output is correct |
16 |
Correct |
54 ms |
3932 KB |
Output is correct |
17 |
Correct |
55 ms |
3932 KB |
Output is correct |
18 |
Correct |
54 ms |
3928 KB |
Output is correct |
19 |
Correct |
65 ms |
3932 KB |
Output is correct |
20 |
Correct |
58 ms |
3972 KB |
Output is correct |
21 |
Correct |
32 ms |
3932 KB |
Output is correct |
22 |
Correct |
35 ms |
3932 KB |
Output is correct |
23 |
Correct |
28 ms |
3928 KB |
Output is correct |
24 |
Correct |
40 ms |
3928 KB |
Output is correct |
25 |
Correct |
36 ms |
3932 KB |
Output is correct |
26 |
Runtime error |
5 ms |
7772 KB |
Execution killed with signal 11 |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3932 KB |
Output is correct |
2 |
Correct |
2 ms |
3884 KB |
Output is correct |
3 |
Correct |
2 ms |
3932 KB |
Output is correct |
4 |
Correct |
1 ms |
3932 KB |
Output is correct |
5 |
Correct |
2 ms |
3932 KB |
Output is correct |
6 |
Correct |
2 ms |
3932 KB |
Output is correct |
7 |
Correct |
2 ms |
3932 KB |
Output is correct |
8 |
Correct |
1 ms |
3932 KB |
Output is correct |
9 |
Correct |
2 ms |
4184 KB |
Output is correct |
10 |
Correct |
2 ms |
3932 KB |
Output is correct |
11 |
Correct |
29 ms |
4876 KB |
Output is correct |
12 |
Correct |
18 ms |
4444 KB |
Output is correct |
13 |
Correct |
20 ms |
4700 KB |
Output is correct |
14 |
Correct |
24 ms |
4692 KB |
Output is correct |
15 |
Correct |
23 ms |
4700 KB |
Output is correct |
16 |
Correct |
24 ms |
4744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3932 KB |
Output is correct |
2 |
Correct |
2 ms |
3884 KB |
Output is correct |
3 |
Correct |
2 ms |
3932 KB |
Output is correct |
4 |
Correct |
1 ms |
3932 KB |
Output is correct |
5 |
Correct |
2 ms |
3932 KB |
Output is correct |
6 |
Correct |
2 ms |
3932 KB |
Output is correct |
7 |
Correct |
2 ms |
3932 KB |
Output is correct |
8 |
Correct |
1 ms |
3932 KB |
Output is correct |
9 |
Correct |
2 ms |
4184 KB |
Output is correct |
10 |
Correct |
2 ms |
3932 KB |
Output is correct |
11 |
Correct |
29 ms |
4876 KB |
Output is correct |
12 |
Correct |
18 ms |
4444 KB |
Output is correct |
13 |
Correct |
20 ms |
4700 KB |
Output is correct |
14 |
Correct |
24 ms |
4692 KB |
Output is correct |
15 |
Correct |
23 ms |
4700 KB |
Output is correct |
16 |
Correct |
24 ms |
4744 KB |
Output is correct |
17 |
Correct |
2 ms |
3932 KB |
Output is correct |
18 |
Correct |
2 ms |
3932 KB |
Output is correct |
19 |
Correct |
2 ms |
3992 KB |
Output is correct |
20 |
Correct |
52 ms |
3968 KB |
Output is correct |
21 |
Runtime error |
10 ms |
7768 KB |
Execution killed with signal 6 |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3932 KB |
Output is correct |
2 |
Correct |
2 ms |
3884 KB |
Output is correct |
3 |
Correct |
2 ms |
3932 KB |
Output is correct |
4 |
Correct |
1 ms |
3932 KB |
Output is correct |
5 |
Correct |
2 ms |
3932 KB |
Output is correct |
6 |
Correct |
2 ms |
3932 KB |
Output is correct |
7 |
Correct |
2 ms |
3932 KB |
Output is correct |
8 |
Correct |
1 ms |
3932 KB |
Output is correct |
9 |
Correct |
2 ms |
4184 KB |
Output is correct |
10 |
Correct |
2 ms |
3932 KB |
Output is correct |
11 |
Correct |
29 ms |
4876 KB |
Output is correct |
12 |
Correct |
18 ms |
4444 KB |
Output is correct |
13 |
Correct |
20 ms |
4700 KB |
Output is correct |
14 |
Correct |
24 ms |
4692 KB |
Output is correct |
15 |
Correct |
23 ms |
4700 KB |
Output is correct |
16 |
Correct |
24 ms |
4744 KB |
Output is correct |
17 |
Correct |
2 ms |
3932 KB |
Output is correct |
18 |
Correct |
2 ms |
3932 KB |
Output is correct |
19 |
Correct |
2 ms |
3992 KB |
Output is correct |
20 |
Correct |
52 ms |
3968 KB |
Output is correct |
21 |
Runtime error |
10 ms |
7768 KB |
Execution killed with signal 6 |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3932 KB |
Output is correct |
2 |
Correct |
2 ms |
3884 KB |
Output is correct |
3 |
Correct |
2 ms |
3932 KB |
Output is correct |
4 |
Correct |
1 ms |
3932 KB |
Output is correct |
5 |
Correct |
2 ms |
3932 KB |
Output is correct |
6 |
Correct |
2 ms |
3932 KB |
Output is correct |
7 |
Correct |
2 ms |
3932 KB |
Output is correct |
8 |
Correct |
1 ms |
3932 KB |
Output is correct |
9 |
Correct |
2 ms |
4184 KB |
Output is correct |
10 |
Correct |
2 ms |
3932 KB |
Output is correct |
11 |
Correct |
29 ms |
4876 KB |
Output is correct |
12 |
Correct |
18 ms |
4444 KB |
Output is correct |
13 |
Correct |
20 ms |
4700 KB |
Output is correct |
14 |
Correct |
24 ms |
4692 KB |
Output is correct |
15 |
Correct |
23 ms |
4700 KB |
Output is correct |
16 |
Correct |
24 ms |
4744 KB |
Output is correct |
17 |
Correct |
2 ms |
3932 KB |
Output is correct |
18 |
Correct |
2 ms |
3932 KB |
Output is correct |
19 |
Correct |
2 ms |
3992 KB |
Output is correct |
20 |
Correct |
52 ms |
3968 KB |
Output is correct |
21 |
Runtime error |
10 ms |
7768 KB |
Execution killed with signal 6 |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3928 KB |
Output is correct |
2 |
Correct |
2 ms |
3932 KB |
Output is correct |
3 |
Correct |
2 ms |
3992 KB |
Output is correct |
4 |
Correct |
2 ms |
3932 KB |
Output is correct |
5 |
Correct |
2 ms |
3932 KB |
Output is correct |
6 |
Correct |
2 ms |
3932 KB |
Output is correct |
7 |
Correct |
1 ms |
3932 KB |
Output is correct |
8 |
Correct |
2 ms |
3932 KB |
Output is correct |
9 |
Correct |
1 ms |
3932 KB |
Output is correct |
10 |
Correct |
1 ms |
3816 KB |
Output is correct |
11 |
Correct |
2 ms |
3928 KB |
Output is correct |
12 |
Correct |
2 ms |
3932 KB |
Output is correct |
13 |
Correct |
1 ms |
3932 KB |
Output is correct |
14 |
Correct |
68 ms |
3980 KB |
Output is correct |
15 |
Correct |
27 ms |
3932 KB |
Output is correct |
16 |
Correct |
54 ms |
3932 KB |
Output is correct |
17 |
Correct |
55 ms |
3932 KB |
Output is correct |
18 |
Correct |
54 ms |
3928 KB |
Output is correct |
19 |
Correct |
65 ms |
3932 KB |
Output is correct |
20 |
Correct |
58 ms |
3972 KB |
Output is correct |
21 |
Correct |
32 ms |
3932 KB |
Output is correct |
22 |
Correct |
35 ms |
3932 KB |
Output is correct |
23 |
Correct |
28 ms |
3928 KB |
Output is correct |
24 |
Correct |
40 ms |
3928 KB |
Output is correct |
25 |
Correct |
36 ms |
3932 KB |
Output is correct |
26 |
Runtime error |
5 ms |
7772 KB |
Execution killed with signal 11 |
27 |
Halted |
0 ms |
0 KB |
- |