#include <bits/stdc++.h>
using namespace std;
int n, w, k;
int inf, l, r, sum, val, ans;
int a[200005], f[200005], _f[200005], h[200005], _h[200005];
namespace Min {
int minn[200005 * 4];
void update(int now) {
  if (_h[minn[now << 1]] <= _h[minn[now << 1 | 1]])
    minn[now] = minn[now << 1];
  else
    minn[now] = minn[now << 1 | 1];
}
void build(int now, int l, int r) {
  int mid = (l + r) >> 1;
  if (l == r) {
    minn[now] = l;
    return;
  }
  build(now << 1, l, mid);
  build(now << 1 | 1, mid + 1, r);
  update(now);
}
void change(int now, int l, int r, int x) {
  int mid = (l + r) >> 1;
  if (l == r) {
    minn[now] = x;
    return;
  }
  if (x <= mid)
    change(now << 1, l, mid, x);
  else
    change(now << 1 | 1, mid + 1, r, x);
  update(now);
}
int query(int now, int l, int r, int lrange, int rrange) {
  if (lrange > rrange) return 0;
  int mid = (l + r) >> 1, ans = 0;
  if (lrange <= l && r <= rrange) return minn[now];
  if (lrange <= mid) {
    int q = query(now << 1, l, mid, lrange, rrange);
    if (_h[ans] > _h[q]) ans = q;
  }
  if (mid + 1 <= rrange) {
    int q = query(now << 1 | 1, mid + 1, r, lrange, rrange);
    if (_h[ans] > _h[q]) ans = q;
  }
  return ans;
}
}  // namespace Min
namespace Max {
int maxn[200005 * 4];
void update(int now) {
  if (_f[maxn[now << 1]] >= _f[maxn[now << 1 | 1]])
    maxn[now] = maxn[now << 1];
  else
    maxn[now] = maxn[now << 1 | 1];
}
void build(int now, int l, int r) {
  int mid = (l + r) >> 1;
  if (l == r) {
    maxn[now] = l;
    return;
  }
  build(now << 1, l, mid);
  build(now << 1 | 1, mid + 1, r);
  update(now);
}
void change(int now, int l, int r, int x) {
  int mid = (l + r) >> 1;
  if (l == r) {
    maxn[now] = x;
    return;
  }
  if (x <= mid)
    change(now << 1, l, mid, x);
  else
    change(now << 1 | 1, mid + 1, r, x);
  update(now);
}
int query(int now, int l, int r, int lrange, int rrange) {
  if (lrange > rrange) return 0;
  int mid = (l + r) >> 1, ans = 0;
  if (lrange <= l && r <= rrange) return maxn[now];
  if (lrange <= mid) {
    int q = query(now << 1, l, mid, lrange, rrange);
    if (_f[ans] < _f[q]) ans = q;
  }
  if (mid + 1 <= rrange) {
    int q = query(now << 1 | 1, mid + 1, r, lrange, rrange);
    if (_f[ans] < _f[q]) ans = q;
  }
  return ans;
}
}  // namespace Max
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", &f[i]);
    _f[i] = f[i];
    h[i] = (f[i] - 1) / 2 + 1;
  }
  memset(_h, 127, sizeof(_h));
  inf = _h[0];
  Max::build(1, 1, n);
  Min::build(1, 1, n);
  while (l <= n) {
    if (l <= r) {
      val -= a[l];
      if (_h[l] != inf) {
        sum -= h[l];
        int loc = Max::query(1, 1, n, l, r);
        if (loc) {
          sum -= f[loc] - h[loc];
          _f[loc] = 0;
          _h[loc] = h[loc];
          Max::change(1, 1, n, loc);
          Min::change(1, 1, n, loc);
        } else
          ++w;
      } else
        sum -= f[l];
    }
    ++l;
    r = max(r, l - 1);
    while (r < n) {
      if (w) {
        if (sum + h[r + 1] <= k) {
          sum += h[r + 1];
          _f[r + 1] = 0;
          _h[r + 1] = h[r + 1];
          Max::change(1, 1, n, r + 1);
          Min::change(1, 1, n, r + 1);
          --w;
          val += a[++r];
        } else
          break;
      } else {
        int loc = Min::query(1, 1, n, l, r);
        if (loc && f[loc] - h[loc] < f[r + 1] - h[r + 1] &&
            sum - h[loc] + f[loc] + h[r + 1] <= k) {
          sum += f[loc] - h[loc];
          _f[loc] = f[loc];
          _h[loc] = inf;
          Max::change(1, 1, n, loc);
          Min::change(1, 1, n, loc);
          sum += h[r + 1];
          _f[r + 1] = 0;
          _h[r + 1] = h[r + 1];
          Max::change(1, 1, n, r + 1);
          Min::change(1, 1, n, r + 1);
          val += a[++r];
        } else if (sum + f[r + 1] <= k) {
          sum += f[r + 1];
          val += a[++r];
        } else
          break;
      }
    }
    ans = max(ans, val);
  }
  printf("%d\n", ans);
}
