Submission #968299

#TimeUsernameProblemLanguageResultExecution timeMemory
968299Vladth11Team Contest (JOI22_team)C++14
0 / 100
2086 ms348 KiB
#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 = 100005; 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(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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...