#include <bits/stdc++.h>
using namespace std;
struct maxsum {
  int k;
  multiset<int> big;
  multiset<int, greater<int>> small;
  int sum = 0;
  maxsum(int k) : k(k) {}
  void add(int x) {
    big.insert(x);
    sum += x;
    if (big.size() > k) {
      x = *big.begin();
      big.erase(big.begin());
      sum -= x;
      small.insert(x);
    }
  }
  void del(int x) {
    auto it = big.find(x);
    if (it != big.end()) {
      big.erase(it);
      sum -= x;
      if (!small.empty()) {
        x = *small.begin();
        small.erase(small.begin());
        big.insert(x);
        sum += x;
      }
    } else {
      it = small.find(x);
      if (it != small.end()) {
        small.erase(it);
      }
    }
  }
};
int main() {
  ios::sync_with_stdio(false);
  int n, w, k;
  scanf("%d%d%d", &n, &w, &k);
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  vector<int> t(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &t[i]);
  }
  int ans = 0;
  int x = 0;
  int asum = 0;
  int tsum = 0;
  maxsum tt(w);
  for (int i = 0; i < n; i++) {
    asum += a[i];
    tsum += t[i];
    tt.add(t[i] / 2);
    while (tsum - tt.sum > k) {
      asum -= a[x];
      tsum -= t[x];
      tt.del(t[x] / 2);
      x++;
    }
    ans = max(ans, asum);
  }
  printf("%d\n", ans);
  return 0;
}
