Submission #887584

#TimeUsernameProblemLanguageResultExecution timeMemory
887584MinaRagy06Team Contest (JOI22_team)C++17
0 / 100
2085 ms3932 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const ll inf = 1e18; int main() { ios_base::sync_with_stdio(0), cin.tie(0); int n; cin >> n; array<ll, 3> a[n]; for (int i = 0; i < n; i++) { cin >> a[i][0] >> a[i][1] >> a[i][2]; } sort(a, a + n); ll ans = -1; int cur = 0; for (int i = 0; i < n; i++) { while (a[cur][0] < a[i][0]) cur++; auto solve = [&] () { array<ll, 2> mx1[2]; for (int j = 0; j < 2; j++) { mx1[j] = {-inf, -inf}; } for (int j = 0; j < cur; j++) { array<ll, 2> val = {a[j][1], -a[j][2]}; if (val[0] == mx1[0][0]) { mx1[0] = max(mx1[0], val); } else { if (val > mx1[1]) { mx1[1] = val; } if (mx1[1] > mx1[0]) { swap(mx1[0], mx1[1]); } } } mx1[0][1] *= -1, mx1[1][1] *= -1; for (int k = 0; k < 2; k++) { array<ll, 2> mx2 = {-inf, -inf}; for (int j = 0; j < cur; j++) { if (a[j][1] < mx1[k][0]) { mx2 = max(mx2, {a[j][2], -a[j][1]}); } } mx2[1] *= -1; if (mx1[k][0] > a[i][1] && mx1[k][0] > mx2[1] && mx2[0] > a[i][2] && mx2[0] > mx1[k][1]) { ans = max(ans, a[i][0] + mx1[k][0] + mx2[0]); } } }; solve(); for (int j = 0; j < cur; j++) { swap(a[j][1], a[j][2]); } swap(a[i][1], a[i][2]); solve(); for (int j = 0; j < cur; j++) { swap(a[j][1], a[j][2]); } swap(a[i][1], a[i][2]); } cout << ans << '\n'; return 0; }
#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...