#include <bits/stdc++.h>
using namespace std;
multiset<int> half, full;
int a[200010], t[200010], n, w, k, ti, cur_sat, res;
int main() {
  scanf("%d%d%d", &n, &w, &k);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i) scanf("%d", &t[i]);
  int l = 1, r = 1;
  while (r <= n) {
    half.insert(t[r]);
    ti += (t[r] + 1) / 2;
    if (half.size() > w) {
      full.insert(*(half.begin()));
      ti += *(half.begin()) / 2;
      half.erase(half.begin());
    }
    cur_sat += a[r];
    ++r;
    while (l <= r && ti > k) {
      if (t[l] >= *(half.begin())) {
        half.erase(half.find(t[l]));
        ti -= (t[l] + 1) / 2;
        if (full.size()) {
          multiset<int>::iterator pos;
          pos = full.end();
          --pos;
          half.insert(*pos);
          ti -= *pos / 2;
          full.erase(pos);
        }
      } else {
        full.erase(full.find(t[l]));
        ti -= t[l];
      }
      cur_sat -= a[l];
      ++l;
    }
    res = max(res, cur_sat);
  }
  printf("%d\n", res);
}
