#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 2e5 + 10;
long long n, k, w, tot, val, ans;
struct node {
  long long v, t, id, b;
  inline bool operator<(const node& x) const { return t < x.t; }
} a[MAXN];
multiset<long long> s1, s2;
multiset<long long>::iterator it;
signed main() {
  ios ::sync_with_stdio(0), cin.tie(0);
  cin >> n >> w >> k;
  for (long long i = 1; i <= n; i++) cin >> a[i].v;
  for (long long i = 1; i <= n; i++) cin >> a[i].t, a[i].b = (a[i].t + 1) / 2;
  long long l = 1, r = 1;
  while (r <= n) {
    tot += a[r].b;
    val += a[r].v;
    s2.insert(a[r].t);
    if (s2.size() > w) {
      it = s2.begin();
      tot += *it - (*it + 1) / 2;
      s2.erase(it);
      s1.insert(*it);
    }
    while (l <= r && tot > k) {
      it = s2.begin();
      if (a[l].t < *it) {
        tot -= a[l].t;
        val -= a[l].v;
        s1.erase(s1.find(a[l].t));
      } else {
        tot -= (a[l].b);
        val -= a[l].v;
        s2.erase(s2.find(a[l].t));
        while (s2.size() < w && !s1.empty()) {
          it = s1.end();
          it--;
          s2.insert(*it);
          s1.erase(it);
          tot -= *it - (*it + 1) / 2;
        }
      }
      l++;
    }
    ans = max(ans, val);
    r++;
  }
  cout << ans << endl;
  return 0;
}
