Submission #561509

#TimeUsernameProblemLanguageResultExecution timeMemory
561509gg123_peDivide and conquer (IZhO14_divide)C++14
100 / 100
128 ms11972 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...