Link to this code:
https://cses.fi/paste/9f2e28ce959484e426d2e2//*
author: @ankingcodes
created: 2021-07-20 13:55:39.959135
*/
#include<bits/stdc++.h>
#include<algorithm>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define INF 1e18
#define MOD 1000000007
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> PBDS;
typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag,
tree_order_statistics_node_update> pairPBDS;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n, a, b; cin >> n >> a >> b;
vector<ll> pf(n+1);
for (int i=1;i<=n;i++){
ll x; cin >> x;
pf[i] = pf[i-1] + x;
}
set<ll> s;
for (int i=a;i<=b;i++)
s.insert(pf[i]);
ll mxs = -INF;
for (int i=1;i<=n-a+1;i++) {
mxs = max(mxs, *s.rbegin() - pf[i-1]);
s.erase(pf[i+a-1]);
if (i + b <= n)
s.insert(pf[i+b]);
}
cout << mxs << endl;
return 0;
}