#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int a[N];
int t[N];
struct k_max {
  int sum_len;
  int sum_t;
  int k;
  set<pair<int, int> > big;
  set<pair<int, int> > small;
  k_max() {}
  k_max(int _k) : sum_len(0), sum_t(0), k(_k) {}
  void add(int m) {
    sum_len += (a[m] + 1) / 2;
    sum_t += t[m];
    big.insert(pair<int, int>(a[m], m));
    if (big.size() > k) {
      auto p = big.begin();
      sum_len -= (p->first + 1) / 2 - p->first;
      small.insert(*p);
      big.erase(p);
    }
  }
  void del(int m) {
    auto it = big.find(pair<int, int>(a[m], m));
    if (it != big.end()) {
      sum_t -= t[m];
      sum_len -= (it->first + 1) / 2;
      big.erase(it);
      if (!small.empty()) {
        auto it = small.end();
        it--;
        sum_len -= it->first;
        sum_len += (it->first + 1) / 2;
        big.insert(*it);
        small.erase(it);
      }
    } else {
      sum_t -= t[m];
      sum_len -= a[m];
      small.erase(pair<int, int>(a[m], m));
    }
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  int n, w, k;
  cin >> n >> w >> k;
  for (int i = 0; i < n; i++) cin >> t[i];
  for (int i = 0; i < n; i++) cin >> a[i];
  k_max T(w);
  int l = 0;
  int r = 0;
  int ans = 0;
  while (true) {
    if (T.sum_len <= k) {
      ans = max(ans, T.sum_t);
      if (r != n) {
        T.add(r);
        r++;
      } else {
        break;
      }
    } else {
      if (l != n) {
        T.del(l);
        l++;
      } else {
        break;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
