This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,popcnt,sse4,abm")
#include<bits/stdc++.h>
#define int long long
#define quick ios::sync_with_stdio(0);cin.tie(0);
#define rep(x,a,b) for(int x=a;x<=b;x++)
#define repd(x,a,b) for(int x=a;x>=b;x--)
#define lowbit(x) (x&-x)
#define sz(x) (int)(x.size())
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define mp make_pair
#define eb emplace_back
using namespace std;
typedef pair<int,int> pii;
void debug(){
cout<<"\n";
}
template <class T,class ... U >
void debug(T a, U ... b){
cout<<a<<" ",debug(b...);
}
const int N=2e5+7;
const int INF=1e18;
int p[3][N];
int get(int a,int b,int c,int idx){
if(p[idx][a]<p[idx][b]) swap(a,b);
if(p[idx][a]<p[idx][c]) swap(a,c);
if(p[idx][a]==p[idx][b]||p[idx][a]==p[idx][c]) return -1;
return a;
}
signed main(){
quick
int n;
cin>>n;
rep(i,1,n){
rep(j,0,2) cin>>p[j][i];
}
int ans=-1;
rep(i,1,n){
rep(j,i+1,n){
rep(z,j+1,n){
int px[3];
bool ok=true;
int sum=0;
rep(d,0,2) {
px[d]=get(i,j,z,d);
sum+=p[d][px[d]];
if(px[d]==-1) ok=false;
rep(d2,0,d-1){
if(px[d]==px[d2]) ok=false;
}
}
if(ok) ans=max(ans,sum);
}
}
}
cout<<ans<<"\n";
return 0;
}
Compilation message (stderr)
team.cpp: In function 'int main()':
team.cpp:50:21: warning: array subscript -1 is below array bounds of 'long long int [200007]' [-Warray-bounds]
50 | sum+=p[d][px[d]];
| ~~~~~~~~~~^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |