#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
int n, w, k;
int a[MAXN], t[MAXN];
multiset<int> q1, q2;
int ans;
int upt(int tt) {
  if (tt % 2 == 0) {
    return tt / 2;
  } else
    return tt / 2 + 1;
}
int main(int argc, const char* argv[]) {
  cin >> n >> w >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
  }
  int ct = 0;
  int ca = 0;
  int cw = 0;
  int l = 1, r = 1;
  while (1) {
    if (cw < w) {
      ct += upt(t[r]);
      q1.insert(t[r]);
      ca += a[r];
      r++;
      cw++;
    } else {
      auto it = q1.begin();
      int tt = *it;
      if (tt < t[r]) {
        q1.erase(it);
        q1.insert(t[r]);
        ct += upt(t[r]);
        ct += tt / 2;
        ca += a[r];
        q2.insert(tt);
      } else {
        q2.insert(t[r]);
        ct += t[r];
        ca += a[r];
      }
      r++;
    }
    while (ct > k) {
      int tt = t[l];
      if (q2.count(tt) != 0) {
        auto it = q2.find(tt);
        q2.erase(it);
        ct -= tt;
        ca -= a[l];
      } else {
        auto it = q1.find(tt);
        q1.erase(it);
        ct -= upt(tt);
        ca -= a[l];
        if (!q2.empty()) {
          auto it = q2.end();
          it--;
          int ttt = *it;
          q2.erase(it);
          q1.insert(ttt);
          ct -= ttt / 2;
          cw++;
        }
        cw--;
      }
      l++;
    }
    ans = max(ans, ca);
    if (r == n + 1) {
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
