#include <bits/stdc++.h>
struct dta {
  int val, id;
  dta(int _v = 0, int _id = 0) {
    val = _v;
    id = _id;
  }
};
struct c1 {
  bool operator()(const dta &x, const dta &y) const {
    return (x.val < y.val || (x.val == y.val && x.id < y.id));
  }
};
struct c2 {
  bool operator()(const dta &x, const dta &y) const {
    return (x.val > y.val || (x.val == y.val && x.id < y.id));
  }
};
using namespace std;
int n, w, k, A[200001], B[200001], P[200001];
set<dta, c2> Qchua;
set<dta, c1> Qroi;
vector<dta> tam;
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", &B[i]);
  for (int i = 1; i <= n; i++) P[i] = 0;
  int l = n, r = n;
  int t = B[n], tval = A[n], cur = 0;
  Qchua.insert(dta(B[n], n));
  int res = 0;
  set<dta>::iterator q;
  while (l >= 1) {
    if (cur < w) {
      for (q = Qchua.begin(); q != Qchua.end(); ++q) {
        dta u = *q;
        t -= (u.val / 2);
        tam.push_back(u);
        cur++;
        P[u.id] = 1;
        if (cur == w) break;
      }
      while (!tam.empty()) {
        dta u = tam.back();
        Qroi.insert(u);
        Qchua.erase(u);
        tam.pop_back();
      }
    }
    if (!P[l]) {
      dta u = *(Qroi.begin());
      if (u.val < B[l]) {
        Qroi.erase(u);
        P[l] = 1;
        Qchua.insert(u);
        Qchua.erase(dta(B[l], l));
        Qroi.insert(dta(B[l], l));
        t -= (B[l] / 2);
        t += (u.val / 2);
        P[u.id] = 0;
      }
    }
    if (t <= k) {
      res = max(res, tval);
      l--;
      if (!l) continue;
      t += B[l];
      tval += A[l];
      Qchua.insert(dta(B[l], l));
      continue;
    }
    while (t > k && l <= r) {
      if (P[r]) {
        t -= (B[r] / 2 + B[r] % 2);
        tval -= (A[r]);
        cur--;
        Qroi.erase(dta(B[r], r));
        P[r] = 0;
      } else {
        t -= B[r];
        tval -= (A[r]);
        Qchua.erase(dta(B[r], r));
      }
      r--;
    }
    res = max(res, tval);
    l--;
    if (!l) continue;
    t += B[l];
    tval += A[l];
    Qchua.insert(dta(B[l], l));
  }
  printf("%d", res);
  return 0;
}
