#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<int, int> > ma;
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    mi;
int timp, pleasure, a[200005], t[200005], misize, w, st, f[200005], n, k, i,
    ans;
void update() {
  while (misize < w and !ma.empty()) {
    if (ma.top().second < st) {
      ma.pop();
      continue;
    }
    mi.push(ma.top()), misize++;
    timp -= t[ma.top().second] / 2;
    f[ma.top().second] = 1;
    ma.pop();
  }
  while (misize > 0 and !ma.empty() and ma.top().first > mi.top().first) {
    if (ma.top().second < st) {
      ma.pop();
      continue;
    }
    if (mi.top().second < st) {
      mi.pop();
      continue;
    }
    pair<int, int> x, y;
    x = ma.top();
    y = mi.top();
    timp -= ma.top().first / 2;
    timp += mi.top().first / 2;
    f[x.second] = 1;
    f[y.second] = 0;
    ma.pop(), mi.pop();
    ma.push(y), mi.push(x);
  }
}
int main() {
  cin >> n >> w >> k;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) cin >> t[i];
  st = 1;
  for (i = 1; i <= n; i++) {
    ma.push({t[i], i});
    timp += t[i];
    pleasure += a[i];
    update();
    while (timp > k) {
      if (f[st] == 1)
        timp -= (t[st] + 1) / 2, misize--;
      else
        timp -= t[st];
      pleasure -= a[st];
      st++;
      update();
    }
    ans = max(ans, pleasure);
  }
  cout << ans << "\n";
  return 0;
}
