#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("Ofast,unroll-loops")
#define pii pair<int,int>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define int long long
#define f first
#define s second
#define pii pair<int,int>
template<class T>bool umax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>bool umin(T &a,T b){if(b<a){a=b;return true;}return false;}
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
const int mod= 1e9 +7;
const int N=1e5*4;
int binpow (int a, int n) {
if (n == 0)
return 1;
if (n % 2 == 1)
return binpow (a, n-1) * a;
else {
int b = binpow (a, n/2);
return b * b;
}
}
void solve(){
int n,m,k;
cin>>n;
if(n<=300){
vector<int>a(n+1),b(n+1),c(n+1);
int sum = 0;
for(int i = 0;i<n;i++){
cin>>a[i]>>b[i]>>c[i];
}
int mx = -1;
for(int i = 0;i<n;i++){
for(int j = 0;j<n;j++){
if(i==j)continue;
for(int k = 0;k<n;k++){
if(k==i||k==j)continue;
sum = 0;
sum = a[i] + b[j] + c[k];
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])umax(mx,sum);
}
}
}
cout<<mx<<endl;
return;
}
map<pair<int,pii>,int>mp;
for(int i = 0;i<n;i++){
int a,b,c;
cin>>a>>b>>c;
mp[{a,{b,c}}]++;
}
vector<pair<int,pii>>u;
for(int i = 1;i<=5;i++){
for(int j = 1;j<=5;j++){
for(int k = 1;k<=5;k++){
u.pb({i,{j,k}});
}
}
}
int mx = -1;
for(auto to:u){
if(mp[to]==0)continue;
map<pair<int,pii>,int>mp1 = mp;
mp1[to]--;
for(auto i:u){
if(mp1[i]==0)continue;
map<pair<int,pii>,int>mp2 = mp1;
mp2[i]--;
for(auto j:u){
if(mp2[j]==0)continue;
int sum = to.f+i.s.f+j.s.s;
/*if(sum==13){
cout<<to.f<<" "<<to.s.f<<" "<<to.s.s<<"\n";
cout<<i.f<<" "<<i.s.f<<" "<<i.s.s<<"\n";
cout<<j.f<<" "<<j.s.f<<" "<<j.s.s<<"\n";
}*/
if(to.f>i.f&&to.f>j.f&& i.s.f>to.s.f&&i.s.f>j.s.f&& j.s.s>i.s.s&&j.s.s>to.s.s)umax(mx,sum);
}
}
}
cout<<mx<<endl;
}
signed main()
{
// freopen("seq.in", "r", stdin);
// freopen("seq.out", "w", stdout);
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int tt=1;//cin>>tt;
while(tt--)solve();
}
Compilation message
team.cpp: In function 'void solve()':
team.cpp:36:8: warning: unused variable 'm' [-Wunused-variable]
36 | int n,m,k;
| ^
team.cpp:36:10: warning: unused variable 'k' [-Wunused-variable]
36 | int n,m,k;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 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 |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 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 |
92 ms |
348 KB |
Output is correct |
15 |
Correct |
45 ms |
348 KB |
Output is correct |
16 |
Correct |
62 ms |
348 KB |
Output is correct |
17 |
Correct |
60 ms |
440 KB |
Output is correct |
18 |
Correct |
68 ms |
436 KB |
Output is correct |
19 |
Correct |
88 ms |
444 KB |
Output is correct |
20 |
Correct |
72 ms |
516 KB |
Output is correct |
21 |
Correct |
50 ms |
348 KB |
Output is correct |
22 |
Correct |
49 ms |
348 KB |
Output is correct |
23 |
Correct |
41 ms |
440 KB |
Output is correct |
24 |
Correct |
50 ms |
348 KB |
Output is correct |
25 |
Correct |
49 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 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 |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 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 |
92 ms |
348 KB |
Output is correct |
15 |
Correct |
45 ms |
348 KB |
Output is correct |
16 |
Correct |
62 ms |
348 KB |
Output is correct |
17 |
Correct |
60 ms |
440 KB |
Output is correct |
18 |
Correct |
68 ms |
436 KB |
Output is correct |
19 |
Correct |
88 ms |
444 KB |
Output is correct |
20 |
Correct |
72 ms |
516 KB |
Output is correct |
21 |
Correct |
50 ms |
348 KB |
Output is correct |
22 |
Correct |
49 ms |
348 KB |
Output is correct |
23 |
Correct |
41 ms |
440 KB |
Output is correct |
24 |
Correct |
50 ms |
348 KB |
Output is correct |
25 |
Correct |
49 ms |
348 KB |
Output is correct |
26 |
Incorrect |
2 ms |
604 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
424 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 |
352 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
99 ms |
464 KB |
Output is correct |
12 |
Correct |
44 ms |
448 KB |
Output is correct |
13 |
Correct |
36 ms |
456 KB |
Output is correct |
14 |
Correct |
37 ms |
460 KB |
Output is correct |
15 |
Correct |
21 ms |
456 KB |
Output is correct |
16 |
Correct |
17 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
424 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 |
352 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
99 ms |
464 KB |
Output is correct |
12 |
Correct |
44 ms |
448 KB |
Output is correct |
13 |
Correct |
36 ms |
456 KB |
Output is correct |
14 |
Correct |
37 ms |
460 KB |
Output is correct |
15 |
Correct |
21 ms |
456 KB |
Output is correct |
16 |
Correct |
17 ms |
460 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
352 KB |
Output is correct |
20 |
Correct |
67 ms |
352 KB |
Output is correct |
21 |
Incorrect |
21 ms |
860 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
424 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 |
352 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
99 ms |
464 KB |
Output is correct |
12 |
Correct |
44 ms |
448 KB |
Output is correct |
13 |
Correct |
36 ms |
456 KB |
Output is correct |
14 |
Correct |
37 ms |
460 KB |
Output is correct |
15 |
Correct |
21 ms |
456 KB |
Output is correct |
16 |
Correct |
17 ms |
460 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
352 KB |
Output is correct |
20 |
Correct |
67 ms |
352 KB |
Output is correct |
21 |
Incorrect |
21 ms |
860 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
424 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 |
352 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
99 ms |
464 KB |
Output is correct |
12 |
Correct |
44 ms |
448 KB |
Output is correct |
13 |
Correct |
36 ms |
456 KB |
Output is correct |
14 |
Correct |
37 ms |
460 KB |
Output is correct |
15 |
Correct |
21 ms |
456 KB |
Output is correct |
16 |
Correct |
17 ms |
460 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
352 KB |
Output is correct |
20 |
Correct |
67 ms |
352 KB |
Output is correct |
21 |
Incorrect |
21 ms |
860 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 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 |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 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 |
92 ms |
348 KB |
Output is correct |
15 |
Correct |
45 ms |
348 KB |
Output is correct |
16 |
Correct |
62 ms |
348 KB |
Output is correct |
17 |
Correct |
60 ms |
440 KB |
Output is correct |
18 |
Correct |
68 ms |
436 KB |
Output is correct |
19 |
Correct |
88 ms |
444 KB |
Output is correct |
20 |
Correct |
72 ms |
516 KB |
Output is correct |
21 |
Correct |
50 ms |
348 KB |
Output is correct |
22 |
Correct |
49 ms |
348 KB |
Output is correct |
23 |
Correct |
41 ms |
440 KB |
Output is correct |
24 |
Correct |
50 ms |
348 KB |
Output is correct |
25 |
Correct |
49 ms |
348 KB |
Output is correct |
26 |
Incorrect |
2 ms |
604 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |