이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |