This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
constexpr int BASE = 1<<18;
struct cord{
int x, y, z;
};
cord INPUT[BASE];
int n;
int check(int i, int j, int k){
int ilei = 0;
int ilej = 0;
int ilek = 0;
int x = max({INPUT[i].x, INPUT[j].x, INPUT[k].x});
int y = max({INPUT[i].y, INPUT[j].y, INPUT[k].y});
int z = max({INPUT[i].z, INPUT[j].z, INPUT[k].z});
if(INPUT[i].x == x) ilei++;
if(INPUT[i].y == y) ilei++;
if(INPUT[i].z == z) ilei++;
if(INPUT[j].x == x) ilej++;
if(INPUT[j].y == y) ilej++;
if(INPUT[j].z == z) ilej++;
if(INPUT[k].x == x) ilek++;
if(INPUT[k].y == y) ilek++;
if(INPUT[k].z == z) ilek++;
if(ilei == ilej && ilej == ilek && ilej == 1) return x+y+z;
return -1;
}
int solve(){
int res = -1;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= i-1; j++){
for(int k = 1; k <= j-1; k++){
res = max(res, check(i, j, k));
}
}
}
return res;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i = 1; i <= n; i++)
cin >> INPUT[i].x >> INPUT[i].y >> INPUT[i].z;
cout << solve() << "\n";
}
# | 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... |