#include <bits/stdc++.h>
using namespace std;
set<pair<int, int> > seti, setfull;
set<pair<int, int> >::iterator it1, it, it2;
int arr[212345] = {0};
int a[212345] = {0};
int t[212345] = {0};
int main() {
  std::ios::sync_with_stdio(false);
  int n, w, k;
  cin >> n >> w >> k;
  int i = 0;
  int j = 0;
  long long plea = 0;
  long long total = 0;
  long long totalnew = 0;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    cin >> t[i];
  }
  i = 0;
  j = 0;
  long long maxi = 0;
  long long val;
  while (j < n) {
    if (seti.size() < w) {
      if (total + (t[j] + 1) / 2 <= k) {
        seti.insert(make_pair((t[j] + 1) / 2, j));
        arr[j] = 1;
        total += (t[j] + 1) / 2;
        plea += a[j];
        j++;
      } else {
        if (arr[i] == 1) {
          seti.erase(make_pair((t[i] + 1) / 2, i));
          plea -= a[i];
          total -= (t[i] + 1) / 2;
          arr[i] = 0;
        } else {
          j++;
        }
        i++;
      }
    } else {
      it = seti.begin();
      int val = it->second;
      if (t[val] < t[j]) {
        totalnew = total + (t[val]) - (t[val] + 1) / 2 + (t[j] + 1) / 2;
        if (totalnew <= k) {
          seti.erase(it);
          setfull.insert(make_pair(t[val], val));
          arr[val] = 0;
          plea += a[j];
          total = totalnew;
          seti.insert(make_pair((t[j] + 1) / 2, j));
          arr[j] = 1;
          j++;
        } else {
          if (arr[i] == 1) {
            seti.erase(make_pair((t[i] + 1) / 2, i));
            plea -= a[i];
            total -= (t[i] + 1) / 2;
            if (!setfull.empty()) {
              it = setfull.end();
              it--;
              val = it->second;
              arr[val] = 1;
              arr[i] = 0;
              setfull.erase(it);
              total -= t[val];
              total += (t[val] + 1) / 2;
              seti.insert(make_pair((t[val] + 1) / 2, val));
            }
          } else {
            setfull.erase(make_pair(t[i], i));
            plea -= a[i];
            total -= t[i];
          }
          i++;
        }
      } else {
        totalnew = total + t[j];
        if (totalnew <= k) {
          setfull.insert(make_pair(t[j], j));
          plea += a[j];
          total += t[j];
          j++;
        } else {
          if (arr[i] == 1) {
            seti.erase(make_pair((t[i] + 1) / 2, i));
            plea -= a[i];
            total -= (t[i] + 1) / 2;
            arr[i] = 0;
            if (!setfull.empty()) {
              it = setfull.end();
              it--;
              val = it->second;
              arr[val] = 1;
              setfull.erase(it);
              total -= t[val];
              total += (t[val] + 1) / 2;
              seti.insert(make_pair((t[val] + 1) / 2, val));
            }
          } else {
            setfull.erase(make_pair(t[i], i));
            plea -= a[i];
            total -= t[i];
          }
          i++;
        }
      }
    }
    maxi = max(maxi, plea);
  }
  cout << maxi << endl;
}
