Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ll x[300000];
- ll pref[300000];
- int main(){
- ll n, a, b;
- cin>>n>>a>>b;
- x[0]=pref[0]=0;
- for(ll i=1;i<=n;i++){
- cin>>x[i];
- }
- multiset<ll> cur;
- pref[1]=x[1];
- for(ll i=1;i<=n;i++){
- pref[i]=pref[i-1]+x[i];
- }
- ll ans=-2e18;
- for(int i=a;i<=n;i++){
- // dbg(i);
- cur.insert(pref[i-a]);
- if(i>b){
- //erase
- if(cur.find(pref[i-b-1])!=cur.end())
- cur.erase(cur.find(pref[i-b-1]));
- }
- ans=max(ans, pref[i]-*cur.begin());
- }
- cout<<ans<<'\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement