제출 #919847

#제출 시각아이디문제언어결과실행 시간메모리
919847Gwynbleidd_Team Contest (JOI22_team)C++14
100 / 100
710 ms46672 KiB
#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 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...