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;
typedef long long ll;
#define f(i,a,b) for(int i = a; i < b; i++)
const int N = 1e5 + 5;
const ll inf = 1e17 + 100;
int n;
ll a[N], g[N], e[N], sg[N], se[N], ans;
int main(){
cin >> n;
vector <pair<ll,pair<ll,ll>>> v;
f(i,1,n+1) {
cin >> a[i] >> g[i] >> e[i];
sg[i] = sg[i-1] + g[i];
se[i] = se[i-1] + e[i];
v.push_back({se[i] - a[i], {1, -sg[i]}});
v.push_back({se[i-1] - a[i], {0, sg[i-1]}});
}
ll mini = inf;
sort(v.begin(), v.end());
for(auto p: v){
ll y = p.second.second;
if(y < 0){
ans = max(ans, abs(y) - mini);
}
else{
mini = min(mini, y);
}
}
cout << ans << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |