제출 #759865

#제출 시각아이디문제언어결과실행 시간메모리
759865Trunkty금 캐기 (IZhO14_divide)C++14
100 / 100
28 ms11004 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define int ll int n,ans; int x[100005],g[100005],preg[100005],d[100005]; signed main(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> n; for(int i=1;i<=n;i++){ cin >> x[i] >> g[i] >> d[i]; preg[i] = preg[i-1]+g[i]; } vector<vector<int>>v; x[0] = x[1]; int curr=0; for(int i=1;i<=n;i++){ curr -= (x[i]-x[i-1]); if(v.size()==0 or v.back()[0]>curr){ v.push_back({curr,i}); } curr += d[i]; int low=0,high=v.size()-1; while(low!=high){ int mid = (low+high)/2; if(v[mid][0]>curr){ low = mid+1; } else{ high = mid; } } ans = max(ans,preg[i]-preg[v[low][1]-1]); } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...