제출 #1279320

#제출 시각아이디문제언어결과실행 시간메모리
1279320IBory금 캐기 (IZhO14_divide)C++20
0 / 100
1 ms568 KiB
#include <bits/stdc++.h> #define pii pair<ll, ll> typedef long long ll; using namespace std; const int MAX = 100007; ll X[MAX], G[MAX], D[MAX], PD[MAX]; int main() { ios::sync_with_stdio(0); cin.tie(0); int N; cin >> N; for (int i = 1; i <= N; ++i) { cin >> X[i] >> G[i] >> D[i]; G[i] += G[i - 1]; PD[i] = PD[i - 1] + D[i]; } for (int i = 1; i <= N; ++i) { PD[i] = PD[i] - X[i]; } ll ans = 0; set<pii> S; for (int i = N; i >= 0; --i) { for (int j = i; j <= N; ++j) if (PD[i] <= PD[j]) ans = max(ans, G[j] - G[i - 1]); continue; if (S.empty() || (*--S.end()).first < D[i]) S.emplace(D[i], G[i]); auto it = S.lower_bound({D[i], 0}); if (it != S.end()) ans = max(ans, (*it).second - (i ? G[i - 1] : 0)); } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...