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;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
#define ins insert
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n; cin>>n;
vector<int> x(n + 1), y(n + 1), z(n + 1);
vector<bool> ban(n + 1);
int m = n;
for (int i = 1; i <= n; i++){
cin>>x[i]>>y[i]>>z[i];
}
auto get = [&](vector<int>& a){
int out = 0;
for (int i = 1; i <= n; i++){
if (!ban[i]){
out = max(out, a[i]);
}
}
return out;
};
while (m >= 3){
int f1 = get(x), f2 = get(y), f3 = get(z);
bool ind = 1;
for (int i = 1; i <= n; i++){
if (ban[i]) continue;
int cnt = (x[i] >= f1) + (y[i] >= f2) + (z[i] >= f3);
if (cnt > 1){
ban[i] = 1;
m--;
ind = 0;
break;
}
}
if (ind){
cout<<f1 + f2 + f3<<"\n";
return 0;
}
}
cout<<-1<<"\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... |