Submission #751385

#TimeUsernameProblemLanguageResultExecution timeMemory
751385czaudernaTeam Contest (JOI22_team)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; struct zaw{ long long x; long long y; long long z; int i; }; const int N = 15e4+3; zaw arrX[N], arrY[N], arrZ[N]; int used[N]; bool compX(zaw fs, zaw sc){ return fs.x < sc.x; } bool compY(zaw fs, zaw sc){ return fs.y < sc.y; } bool compZ(zaw fs, zaw sc) { return fs.z < sc.z; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n, x, y, z; bool stp=false; cin >> n; for(int i=0; i<n; i++){ cin >> arrX[i].x >> arrX[i].y >> arrX[i].z; arrX[i].i=i; arrY[i]=arrX[i]; arrZ[i]=arrX[i]; } sort(arrX, arrX+n, compX); sort(arrY, arrY+n, compY); sort(arrZ, arrZ+n, compZ); x=y=z=n-1; while(arrX[x].i==arrY[y].i || arrY[y].i==arrZ[z].i || arrZ[z].i==arrX[x].i){ if(arrX[x].i==arrY[y].i){ used[arrX[x].i]++; x--; y--; } if(arrZ[z].i==arrY[y].i){ used[arrZ[z].i]++; z--; y--; } if(arrX[x].i==arrZ[z].i){ used[arrX[x].i]++; x--; z--; } if(x<0 || y<0 || z<0){ stp=true; break; } if(used[arrX[x].i]!=0) x--; if(used[arrY[y].i]!=0) y--; if(used[arrZ[z].i]!=0) z--; if(x<0 || y<0 || z<0){ stp=true; break; } } if(stp) cout << "-1"; else cout << arrX[x].x+arrY[y].y+arrZ[z].z; 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...