이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
set<vector<int>> x, y, z;
for (int i = 0; i < n; i++) {
int a, b, c;
cin >> a >> b >> c;
x.insert({a, b, c});
y.insert({b, c, a});
z.insert({c, a, b});
}
int ans = -1;
while (x.size()) {
vector<int> a = *x.rbegin(), b = *y.rbegin(), c = *z.rbegin();
if (a[1] >= b[0]) {
x.erase(a);
swap(a[0], a[1]);
swap(a[1], a[2]);
y.erase(a);
swap(a[0], a[1]);
swap(a[1], a[2]);
z.erase(a);
} else if (b[1] >= c[0]) {
y.erase(b);
swap(b[0], b[1]);
swap(b[1], b[2]);
z.erase(b);
swap(b[0], b[1]);
swap(b[1], b[2]);
x.erase(b);
} else if (c[1] >= a[0]) {
z.erase(c);
swap(c[0], c[1]);
swap(c[1], c[2]);
x.erase(c);
swap(c[0], c[1]);
swap(c[1], c[2]);
y.erase(c);
} else {
ans = a[0] + b[0] + c[0];
break;
}
}
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |