#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) {
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |