Submission #488878

#TimeUsernameProblemLanguageResultExecution timeMemory
488878SirCovidThe19thDivide and conquer (IZhO14_divide)C++17
100 / 100
130 ms5268 KiB
#include <bits/stdc++.h> using namespace std; const int mx = 1e5 + 5; int n, X[mx]; long long G[mx], E[mx], pre[mx], ans; int main(){ cin >> n; for (int i = 1; i <= n; i++){ cin >> X[i] >> G[i] >> E[i]; G[i] += G[i - 1]; E[i] += E[i - 1]; pre[i] = min(pre[i - 1], E[i - 1] - X[i]); } for (int i = 1; i <= n; i++){ int L = 1, H = i; while (L < H){ int M = (L + H) / 2; (pre[M] <= E[i] - X[i]) ? H = M : L = M + 1; } ans = max(ans, G[i] - G[L - 1]); } cout<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...