#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e6 + 123;
using pii = pair<int,int>;
pii x[N], y[N], z[N];
int ix[N], iy[N], iz[N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
for (int i = 0 ; i < n ; ++ i) {
cin >> ix[i] >> iy[i] >> iz[i];
x[i] = {ix[i], i};
y[i] = {iy[i], i};
z[i] = {iz[i], i};
}
sort(x, x + n);
sort(y, y + n);
sort(z, z + n);
int a = n - 1, b = n - 1, c = n - 1;
while (a >= 0 && b >= 0 && c >= 0) {
int i = x[a].second, j = y[b].second, k = z[c].second;
if (iy[i] == iy[j] || iz[i] == iz[k]) --a;
if (ix[i] == ix[j] || iz[j] == iz[k]) --b;
if (iy[j] == iy[k] || ix[i] == ix[k]) --c;
if (ix[i] > ix[j] && ix[i] > ix[k] && iy[j] > iy[i] && iy[j] > iy[k] &&
iz[k] > iz[i] && iz[k] > iz[j]) {
cout << ix[i] + iy[j] + iz[k];
return 0;
}
}
cout << -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Execution timed out |
2090 ms |
340 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Execution timed out |
2090 ms |
340 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Execution timed out |
2074 ms |
340 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Execution timed out |
2074 ms |
340 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Execution timed out |
2074 ms |
340 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Execution timed out |
2074 ms |
340 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Execution timed out |
2090 ms |
340 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |