Submission #711293

#TimeUsernameProblemLanguageResultExecution timeMemory
711293kostia244Team Contest (JOI22_team)C++17
55 / 100
2067 ms3532 KiB
#include<bits/stdc++.h>
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;

int main() {
    cin.tie(0)->sync_with_stdio(0);
    int n;
    cin >> n;
    vector<array<int, 3>> a(n);
    for(auto &[x, y, z] : a)
        cin >> x >> y >> z;
    sort(all(a));
    a.erase(unique(all(a)), a.end());
    n = a.size();
    ll ans = -1;
    for(int i = 0; i < n; i++) {//z
        ll ymax = -1, upd = -1;
        for(int j = 0; j < n; j++) if(a[j][2] < a[i][2] && (a[j][0] > a[i][0] || a[j][1] > a[i][1])) {//x
            if(ymax >= a[j][1]) {
                if(ymax > max(a[j][1], a[i][1]) && a[j][0] > a[i][0] && upd != a[j][0]) {
                    // if(a[i][2] + ymax + a[j][0] == 14) {
                    //     cout << a[i][0] << " " << a[i][1] << " " << a[i][2] << endl;
                    //     cout << a[j][0] << " " << a[j][1] << " " << a[j][2] << endl;
                    //     cout << ymax << endl << endl;
                    // }
                    ans = max(ans, a[i][2] + ymax + a[j][0]);
                }
            } else
                ymax = a[j][1], upd = a[j][0];
        }
    }
    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...