Submission #971640

#TimeUsernameProblemLanguageResultExecution timeMemory
971640Aiperiii금 캐기 (IZhO14_divide)C++14
17 / 100
1 ms500 KiB
#include <bits/stdc++.h> #define int long long #define ff first #define ss second #define pb push_back #define all(x) x.begin(),x.end() using namespace std; signed main(){ ios_base::sync_with_stdio(); cin.tie(0);cout.tie(0); int n; cin>>n; vector <int> x(n+1),g(n+1),e(n+1),pre(n+1),prg(n+1); for(int i=1;i<=n;i++){ cin>>x[i]>>g[i]>>e[i]; } for(int i=1;i<=n;i++){ pre[i]=pre[i-1]+e[i]; prg[i]=prg[i-1]+g[i]; } int mx=0; for(int i=1;i<=n;i++){ int l=1,r=i; int pos=0; while(l<=r){ int md=(l+r)/2; if(pre[i]-x[i]>=pre[md-1]-x[md]){ r=md-1; pos=md; } else l=md+1; } mx=max(mx,prg[i]-prg[pos-1]); } cout<<mx<<"\n"; } /* 4 0 5 1 1 7 2 4 4 1 7 15 1 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...