#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007LL;
long long base = 37;
long long large = 1000000000000000000LL;
int main() {
  int n, w, k;
  cin >> n >> w >> k;
  vector<int> a(n, 0);
  vector<int> t(n, 0);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> t[i];
  set<pair<int, int> > full, part;
  int r = 0;
  int ti = 0;
  int ans = 0;
  int sum = 0;
  for (int l = 0; l < n; l++) {
    r = max(r, l);
    while (r < n) {
      if (w > (int)part.size()) {
        if (ti + (t[r] + 1) / 2 > k) break;
        part.insert(pair<int, int>(t[r], r));
        ti += (t[r] + 1) / 2;
        sum += a[r];
        while (full.size() > 0) {
          set<pair<int, int> >::iterator it = part.begin();
          set<pair<int, int> >::iterator it2 = full.end();
          it2--;
          if (it2->first > it->first) {
            ti -= (it2->first);
            ti += (it2->first + 1) / 2;
            ti += (it->first);
            ti -= (it->first + 1) / 2;
            pair<int, int> u = *it;
            pair<int, int> v = *it2;
            part.erase(it);
            full.erase(it2);
            full.insert(u);
            part.insert(v);
          } else {
            break;
          }
        }
      } else {
        set<pair<int, int> >::iterator it = part.begin();
        if (t[r] > it->first) {
          int temp = it->first;
          if (ti - (temp + 1) / 2 + temp + (t[r] + 1) / 2 <= k) {
            full.insert(*it);
            part.erase(it);
            part.insert(pair<int, int>(t[r], r));
            sum += a[r];
            ti = ti - (temp + 1) / 2 + temp + (t[r] + 1) / 2;
          } else {
            break;
          }
        } else {
          if (ti + t[r] <= k) {
            ti += t[r];
            sum += a[r];
            full.insert(pair<int, int>(t[r], r));
          } else {
            break;
          }
        }
      }
      r++;
    }
    ans = max(ans, sum);
    bool er = false;
    if (!er) {
      if (part.erase(pair<int, int>(t[l], l))) {
        er = true;
        sum -= a[l];
        ti -= (t[l] + 1) / 2;
      }
    }
    if (!er) {
      if (full.erase(pair<int, int>(t[l], l))) {
        er = true;
        sum -= a[l];
        ti -= t[l];
      }
    }
  }
  cout << ans << endl;
  return 0;
}
