Submission #895131

#TimeUsernameProblemLanguageResultExecution timeMemory
895131anhduc2701Team Contest (JOI22_team)C++17
100 / 100
71 ms17276 KiB
#include<bits/stdc++.h> #define pb push_back #define fi first #define se second using namespace std; typedef long long ll; const int maxn=2e5+5; struct beaver{ ll x,y,z; }B[maxn]; pair<ll,int>X[maxn]; pair<ll,int>Y[maxn]; pair<ll,int>Z[maxn]; int n; signed main(){ cin.tie(0),cout.tie(0)->sync_with_stdio(0); // freopen("input.inp","r",stdin); // freopen("output.out","w",stdout); cin >> n; for(int i=1;i<=n;i++){ cin >> B[i].x >> B[i].y >> B[i].z; X[i]={B[i].x,i}; Y[i]={B[i].y,i}; Z[i]={B[i].z,i}; } sort(X+1,X+1+n); sort(Y+1,Y+1+n); sort(Z+1,Z+1+n); int ptrx=n; int ptry=n; int ptrz=n; ll ans=-1; while(ptrx>0 && ptry>0 && ptrz>0){ if((B[X[ptrx].se].y >= Y[ptry].fi) || (B[X[ptrx].se].z >= Z[ptrz].fi) ){ ptrx--; } else if((B[Y[ptry].se].x >= X[ptrx].fi) || (B[Y[ptry].se].z >= Z[ptrz].fi)){ ptry--; } else if((B[Z[ptrz].se].y >= Y[ptry].fi) || (B[Z[ptrz].se].x >= X[ptrx].fi)){ ptrz--; } else{ ans=X[ptrx].fi+Y[ptry].fi + Z[ptrz].fi; break; } } cout << ans << "\n"; }
#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...