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>
#define ll int
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
using namespace std;
bool check[150005];
ll x[150005], y[150005], z[150005];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
ll n, mx=0, my=0, mz=0; cin >> n;
for (ll i=1; i<=n; i++)
{
cin >> x[i] >> y[i] >> z[i];
mx=max(mx, x[i]), my=max(my, y[i]), mz=max(mz, z[i]);
}
while (1)
{
bool ok=1;
for (ll i=1; i<=n; i++)
if (!check[i] && (x[i]==mx)+(y[i]==my)+(z[i]==mz)>=2)
check[i]=1, ok=0;
if (ok) break;
mx=my=mz=0;
for (ll i=1; i<=n; i++)
if (!check[i])
mx=max(mx, x[i]), my=max(my, y[i]), mz=max(mz, z[i]);
}
if (mx==0 && my==0 && mz==0) cout << -1;
else cout << mx+my+mz << "\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... |