#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000 * 1000 * 1000 + 7;
const long long INF = 1e9 + 100;
const long long LINF = 1e18 + 100;
long long n, w, k;
long long a[200100], t[200100];
long long ps[200100];
set<pair<long long, long long> > s;
set<pair<long long, long long> > ns;
long long ans;
int32_t main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> w >> k;
  for (long long i = (0); i < (n); i++) {
    cin >> a[i];
    ps[i + 1] = ps[i] + a[i];
  }
  for (long long i = (0); i < (n); i++) cin >> t[i];
  ;
  ;
  long long r = 0;
  long long cur = 0;
  for (long long l = (0); l < (n); l++) {
    while (r < n) {
      if ((long long)s.size() < w) {
        if (cur + (t[r] + 1) / 2 <= k) {
          s.insert({t[r], r});
          cur += (t[r] + 1) / 2;
          r++;
        } else
          break;
      } else {
        if (s.begin()->first >= t[r]) {
          if (cur + t[r] <= k) {
            ns.insert({t[r], r});
            cur += t[r];
            r++;
          } else
            break;
        } else {
          long long mt = s.begin()->first;
          if (cur + mt / 2 + (t[r] + 1) / 2 <= k) {
            ns.insert(*s.begin());
            s.erase(s.begin());
            s.insert({t[r], r});
            cur += (t[r] + 1) / 2 + mt / 2;
            r++;
          } else
            break;
        }
      }
    }
    ans = max(ans, ps[r] - ps[l]);
    if (l == r) {
      r++;
      continue;
    }
    if (s.count({t[l], l})) {
      s.erase({t[l], l});
      cur -= (t[l] + 1) / 2;
      if (ns.size()) {
        auto it = ns.end();
        it--;
        s.insert(*it);
        cur -= it->first / 2;
        ns.erase(it);
      }
    } else {
      cur -= t[l];
      ns.erase({t[l], l});
    }
  }
  cout << ans << '\n';
  return 0;
}
