#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
const ll NMAX = 100005;
const ll INF = 1e9;
const ll nrbits = 20;
const ll MOD = 998244353;
int x[NMAX];
int y[NMAX];
int z[NMAX];
int ok[NMAX];
signed main() {
#ifdef HOME
ifstream cin(".in");
ofstream cout(".out");
#endif // HOME
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int i, n;
cin >> n;
for(i = 1; i <= n; i++){
cin >> x[i] >> y[i] >> z[i];
}
int oke = 1;
while(oke){
oke = 0;
int maxx = 0, maxy = 0, maxz = 0;
for(i = 1; i <= n; i++){
if(ok[i] == 1) continue;
maxx = max(maxx, x[i]);
maxy = max(maxy, y[i]);
maxz = max(maxz, z[i]);
}
for(i = 1; i <= n; i++){
int cnt = 0;
if(x[i] == maxx) cnt++;
if(z[i] == maxz) cnt++;
if(y[i] == maxy) cnt++;
if(cnt > 1){
ok[i] = 1;
oke = 1;
}
}
if(oke == 0){
int cnt = 0;
for(i = 1; i <= n; i++) cnt += !ok[i];
if(cnt >= 3){
cout << maxx + maxy + maxz << "\n";
}else{
cout << "-1";
}
return 0;
}
}
cout << "-1";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Execution timed out |
2086 ms |
348 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Execution timed out |
2086 ms |
348 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Execution timed out |
2080 ms |
348 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Execution timed out |
2080 ms |
348 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Execution timed out |
2080 ms |
348 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Execution timed out |
2080 ms |
348 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Execution timed out |
2086 ms |
348 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |