This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |