제출 #172779

#제출 시각아이디문제언어결과실행 시간메모리
172779itgl금 캐기 (IZhO14_divide)C++14
0 / 100
213 ms6532 KiB
#include<bits/stdc++.h> typedef long long ll; using namespace std; ll x[100005]; ll g[100005]; ll d[100005]; ll pos[100005]; pair<ll,ll>vec[100005]; int n; int main(){ cin >> n; for(int i=1;i<=n;i++){ cin>>x[i]>>g[i]>>d[i]; g[i]=g[i]+g[i-1]; d[i]+=d[i-1]; vec[i]=(make_pair(d[i]-x[i],i)); } sort(vec+1,vec+n+1); for(int i=n;i>0;i--){ pos[i]=max(pos[i+1],vec[i].second); } ll res=0; for(int i=1;i<=n;i++){ int mn=d[i-1]-x[i]; int l=0,r=n; if(r-l>0){ int mid=(l+r+1)/2; if(vec[mid].first>=mn) r = mid; else l=mid; } res=max(res,g[pos[r]]-g[i-1]); } cout << res << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...