제출 #887597

#제출 시각아이디문제언어결과실행 시간메모리
887597MinaRagy06Team Contest (JOI22_team)C++17
27 / 100
107 ms2404 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int inf = 1e9; int mn[305], mx[305]; int main() { ios_base::sync_with_stdio(0), cin.tie(0); int n; cin >> n; array<int, 3> a[n]; for (int i = 0; i < n; i++) { cin >> a[i][0] >> a[i][1] >> a[i][2]; } sort(a, a + n); int ans = -1; int cur = 0; for (int i = 0; i < 305; i++) { mn[i] = inf; mx[i] = -inf; } int y = -1; for (int i = 0; i < n; i++) { while (a[cur][0] < a[i][0]) { mx[a[cur][1]] = max(mx[a[cur][1]], a[cur][2]); mn[a[cur][1]] = min(mn[a[cur][1]], a[cur][2]); for (int newy = 304; newy > a[cur][1]; newy--) { if (mn[newy] < a[cur][2]) { y = max(y, newy); break; } } for (int newy = 0; newy < a[cur][1]; newy++) { if (mx[newy] > a[cur][2]) { y = max(y, a[cur][1]); break; } } cur++; } int sufxmx[305]{}; sufxmx[0] = mx[0]; for (int j = 1; j < 305; j++) { sufxmx[j] = max(sufxmx[j - 1], mx[j]); } if (y >= max(1, a[i][1] + 1)) { if (a[i][2] < sufxmx[y - 1]) { ans = max(ans, a[i][0] + sufxmx[y - 1] + y); } } } 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...