제출 #1244151

#제출 시각아이디문제언어결과실행 시간메모리
1244151sula2Team Contest (JOI22_team)C++20
0 / 100
2092 ms4996 KiB
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
using namespace std;
using namespace chrono;

const int N = 150000, A = 4000;
int x[N], y[N], z[N], ind[N];
vector<int> X[A + 1], Y[A + 1], Z[A + 1];

int solve(vector<pair<int,int>> a) {
    sort(all(a), [&](pair<int,int> p1, pair<int,int> p2) {
        auto [x1, y1] = p1;
        auto [x2, y2] = p2;
        return x1 == x2 ? y1 > y2 : x1 < x2;
    });
    int prev_y = -1, mx_z = -1, res = -1e9;
    for (auto [_y, _z] : a) {
        if (_z < mx_z) {
            res = max(res, _y + mx_z);
        }
        if (prev_y < _y) {
            mx_z = max(mx_z, _z);
            prev_y = _y;
        }
    }
    return res;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> z[i];
        ind[i] = 0;
    }
    int ans = -1;
    for (int i = 0; i < n; i++) {
        vector<pair<int,int>> other;
        for (int j = 0; j < n; j++) {
            if (x[j] < x[i] && (y[j] > y[i] || z[j] > z[i])) {
                other.emplace_back(y[j], z[j]);
            }
        }
        ans = max(ans, x[i] + solve(other));
    }
    cout << ans;
}
#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...