이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
 
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
 
const ll NMAX = 150005;
const ll INF = 1e9;
const ll nrbits = 20;
const ll MOD = 998244353;
 
int x[NMAX];
int y[NMAX];
int z[NMAX];
int ok[NMAX];
 
signed main() {
#ifdef HOME
    ifstream cin(".in");
    ofstream cout(".out");
#endif // HOME
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int i, n;
    cin >> n;
    for(i = 1; i <= n; i++){
        cin >> x[i] >> y[i] >> z[i];
    }
    int oke = 1;
    while(oke){
        oke = 0;
        int maxx = 0, maxy = 0, maxz = 0;
        for(i = 1; i <= n; i++){
            if(ok[i] == 1) continue;
            maxx = max(maxx, x[i]);
            maxy = max(maxy, y[i]);
            maxz = max(maxz, z[i]);
        }
        for(i = 1; i <= n; i++){
            int cnt = 0;
            if(ok[i]) continue;
            if(x[i] == maxx) cnt++;
            if(z[i] == maxz) cnt++;
            if(y[i] == maxy) cnt++;
            if(cnt > 1){
                ok[i] = 1;
                oke = 1;
            }
        }
        if(oke == 0){
            int cnt = 0;
            for(i = 1;  i <= n; i++) cnt += !ok[i];
            if(cnt >= 3){
                cout << maxx + maxy + maxz << "\n";
            }else{
                cout << "-1";
            }
            return 0;
        }
    }
    cout << "-1";
    return 0;
}
| # | 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... |