Submission #933808

#TimeUsernameProblemLanguageResultExecution timeMemory
933808velislavgarkovTeam Contest (JOI22_team)C++14
100 / 100
168 ms9804 KiB
#include <iostream> #include <algorithm> using namespace std; struct Player { long long a; int ind; bool friend operator < (Player x, Player y) { return x.a<y.a; } }; const int MAXN=1e5+5e4+10; long long x[MAXN], y[MAXN], z[MAXN]; int posx[MAXN], posy[MAXN], posz[MAXN]; bool used[MAXN]; bool cmpx (int i, int j) { return x[i]<x[j]; } bool cmpy (int i, int j) { return y[i]<y[j]; } bool cmpz (int i, int j) { return z[i]<z[j]; } int main () { int n; cin >> n; for (int i=0;i<n;i++) { cin >> x[i] >> y[i] >> z[i]; posx[i]=posy[i]=posz[i]=i; } sort(posx,posx+n,cmpx); sort(posy,posy+n,cmpy); sort(posz,posz+n,cmpz); int ix, iy, iz; ix=iy=iz=n-1; while (ix>=0 && iy>=0 && iz>=0) { //cout << posx[ix] << ' ' << posy[iy] << ' ' << posz[iz] << endl; if (used[posx[ix]]) { ix--; continue; } if (used[posy[iy]]) { iy--; continue; } if (used[posz[iz]]) { iz--; continue; } if (y[posx[ix]]>=y[posy[iy]] || z[posx[ix]]>=z[posz[iz]]) { used[posx[ix]]=true; ix--; continue; } if (x[posy[iy]]>=x[posx[ix]] || z[posy[iy]]>=z[posz[iz]]) { used[posy[iy]]=true; iy--; continue; } if (x[posz[iz]]>=x[posx[ix]] || y[posz[iz]]>=y[posy[iy]]) { used[posz[iz]]=true; iz--; continue; } cout << x[posx[ix]]+y[posy[iy]]+z[posz[iz]] << endl; return 0; } cout << -1 << endl; } /* 5 3 1 4 2 3 1 1 5 5 4 4 2 5 2 3 */
#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...