#include <bits/stdc++.h>
using namespace std;
const int N = 200000;
set<pair<int, int> > full, half;
int ttime = 0, ples = 0;
int n, w, k;
int a[N], t[N];
int which[N];
void add(int id) {
  ples += a[id];
  if (half.size() < w) {
    ttime += (t[id] + 1) / 2;
    half.insert({t[id], id});
    which[id] = 1;
    return;
  }
  if (t[id] > half.begin()->first) {
    pair<int, int> mov = *half.begin();
    half.erase(half.begin());
    which[mov.second] = 0;
    which[id] = 1;
    full.insert(mov);
    half.insert({t[id], id});
    ttime += mov.first - (mov.first + 1) / 2 + (t[id] + 1) / 2;
    return;
  }
  which[id] = 0;
  ttime += t[id];
  full.insert({t[id], id});
}
void erase(int id) {
  ples -= a[id];
  if (which[id] == 0) {
    ttime -= t[id];
    full.erase({t[id], id});
    return;
  }
  ttime -= (t[id] + 1) / 2;
  half.erase({t[id], id});
  if (full.empty()) return;
  pair<int, int> nw = *full.rbegin();
  ttime += (nw.first + 1) / 2 - nw.first;
  full.erase(full.find(nw));
  which[nw.second] = 1;
  half.insert(nw);
}
int main(int argc, const char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> w >> k;
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  for (int i = 0; i < (int)(n); i++) cin >> t[i];
  int res = 0;
  for (int lf = 0, rg = -1; lf < n; lf++) {
    if (lf) erase(lf - 1);
    if (ttime <= k) res = max(res, ples);
    while (rg < n - 1 && ttime <= k) {
      rg++;
      add(rg);
      if (ttime <= k) res = max(res, ples);
    }
  }
  cout << res;
  return 0;
}
