#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int c[N][2];
int a[N], t[N];
int sa[N], st[N];
pair<int, int> b[N];
int loc[N];
int n, w, k;
void modify(int i, int x, int y) {
  for (; i <= n; i += i & -i) {
    c[i][0] += x;
    c[i][1] += y;
  }
}
int Count() {
  int i = 0, step = 1 << (31 - __builtin_clz(n));
  int t = w, ret = 0;
  for (; step; step >>= 1) {
    if (i + step <= n && c[i + step][0] <= t) {
      t -= c[i += step][0];
      ret += c[i][1];
    }
  }
  return ret;
}
int main() {
  scanf("%d%d%d", &n, &w, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    sa[i] = sa[i - 1] + a[i];
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &t[i]);
    st[i] = st[i - 1] + t[i];
    b[i] = pair<int, int>(t[i] >> 1, i);
  }
  sort(b + 1, b + 1 + n);
  reverse(b + 1, b + 1 + n);
  for (int i = 1; i <= n; ++i) {
    loc[b[i].second] = i;
  }
  int ans = 0;
  for (int r = 1, i = 1; i <= n; ++i) {
    while (st[r - 1] - st[i - 1] - Count() <= k) {
      ans = max(ans, sa[r - 1] - sa[i - 1]);
      if (r > n) break;
      modify(loc[r], 1, t[r] >> 1);
      ++r;
    }
    modify(loc[i], -1, -(t[i] >> 1));
  }
  printf("%d\n", ans);
  return 0;
}
