Submission #768706

#TimeUsernameProblemLanguageResultExecution timeMemory
768706NintsiChkhaidzeTeam Contest (JOI22_team)C++17
64 / 100
2074 ms4264 KiB
#include <bits/stdc++.h> #define pb push_back #define ll long long #define s second #define f first #define left (node<<1),l,((l+r)>>1) #define right ((node<<1)|1),((l+r)>>1) + 1,r // #define int ll using namespace std; const int N = 150005; bool f[N]; int x[N],y[N],z[N]; signed main() { ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL); int n; cin>>n; for (int i = 1; i <= n; i++){ cin>>x[i]>>y[i]>>z[i]; } while (1){ int mxx=0,mxy=0,mxz=0,cnt=0; for (int i= 1; i <= n; i++){ if (!f[i]) { ++cnt; mxx = max(mxx,x[i]); mxy = max(mxy,y[i]); mxz = max(mxz,z[i]); } } if (cnt < 3) break; int del=0; for (int i=1; i <=n; i++){ if (f[i]) continue; cnt=0; if (x[i] == mxx) ++cnt; if (y[i] == mxy) ++cnt; if (z[i] == mxz) ++cnt; if (cnt > 1) f[i] = 1,++del; } if (!del) break; } int mxx=0,mxy=0,mxz=0,cnt=0; for (int i= 1; i <= n; i++){ if (!f[i]) { ++cnt; mxx = max(mxx,x[i]); mxy = max(mxy,y[i]); mxz = max(mxz,z[i]); } } if (cnt < 3){ cout<<-1; }else{ cout<<mxx+mxy+mxz; } }
#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...