#include <bits/stdc++.h>
using namespace std;
void solve(vector<int> rates, vector<int> stra, int k) {
int n = rates.size();
int original = 0;
for(int i=0;i<n;i++) {
original += stra[i] * rates[i];
}
int i=0,j=0,wind=0,owind=0;
int ans = original;
// cout << original << endl;
while(i<n) {
owind += stra[i] * rates[i];
// cout << i << ' ' << j << ' ' << owind << endl;
if(i >= k/2) {
wind += rates[i];
}
if(i-j+1 == k) {
int tans = original - owind + wind;
ans = max(ans, tans);
// cout << j << ' ' << i << ' ' << owind << ' ' << wind << ' ' << tans << endl;
owind -= stra[j]*rates[j];
int mid_ind = (j+k/2);
wind -= rates[mid_ind];
j++;
}
i++;
}
cout << ans << endl;
}
int main() {
solve({2,4,1,5,10,6}, {-1,1,0,1,-1,0}, 4);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp2b2lkIHNvbHZlKHZlY3RvcjxpbnQ+IHJhdGVzLCB2ZWN0b3I8aW50PiBzdHJhLCBpbnQgaykgewoJaW50IG4gPSByYXRlcy5zaXplKCk7CglpbnQgb3JpZ2luYWwgPSAwOwoJZm9yKGludCBpPTA7aTxuO2krKykgewoJCW9yaWdpbmFsICs9IHN0cmFbaV0gKiByYXRlc1tpXTsKCX0KCWludCBpPTAsaj0wLHdpbmQ9MCxvd2luZD0wOwoJaW50IGFucyA9IG9yaWdpbmFsOwoJLy8gY291dCA8PCBvcmlnaW5hbCA8PCBlbmRsOwoJd2hpbGUoaTxuKSB7CgkJb3dpbmQgKz0gc3RyYVtpXSAqIHJhdGVzW2ldOwoJCS8vIGNvdXQgPDwgaSA8PCAgJyAnIDw8IGogPDwgJyAnIDw8IG93aW5kIDw8IGVuZGw7CgkJaWYoaSA+PSBrLzIpIHsKCQkJd2luZCArPSByYXRlc1tpXTsKCQl9CgkJaWYoaS1qKzEgPT0gaykgewoJCQlpbnQgdGFucyA9IG9yaWdpbmFsIC0gb3dpbmQgKyB3aW5kOwoJCQlh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