#include <bits/stdc++.h>
using namespace std;
int const N = 2e5 + 20;
int n, w, k, a[N], t[N], part[N], p = -1, ans, sum1, sum2;
set<pair<int, int> > s1, s2;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> w >> k;
  for (int i = 0; i < n; i++) cin >> a[i], part[i + 1] = part[i] + a[i];
  for (int i = 0; i < n; i++) cin >> t[i];
  for (int i = 0; i < n; i++) {
    p = max(p, i - 1);
    while (p < n && sum1 - sum2 <= k) {
      p++;
      sum1 += t[p];
      if ((int)s1.size() == w && t[p] / 2 <= s1.begin()->first)
        s2.insert({t[p] / 2, p});
      else {
        s1.insert({t[p] / 2, p});
        sum2 += t[p] / 2;
        if ((int)s1.size() > w) {
          pair<int, int> val = *s1.begin();
          sum2 -= val.first;
          s2.insert(val);
          s1.erase(val);
        }
      }
    }
    ans = max(ans, part[p] - part[i]);
    if (p <= i) continue;
    {
      sum1 -= t[i];
      if (s2.find({t[i] / 2, i}) != s2.end())
        s2.erase({t[i] / 2, i});
      else {
        sum2 -= t[i] / 2;
        s1.erase({t[i] / 2, i});
        if ((int)s2.size()) {
          pair<int, int> val = *s2.rbegin();
          sum2 += val.first;
          s1.insert(val), s2.erase(val);
        }
      }
    }
  }
  cout << ans << '\n';
}
