#include <bits/stdc++.h>
using namespace std;
int64_t n, w, k, Time = 0, sum = 0, res = 0, a[200005], t[200005], type[200005];
set<pair<int, int> > half, full;
bool Check(int x, int i) {
  if (half.size() < w && Time + (t[i] + 1) / 2 <= k) {
    Time += (t[i] + 1) / 2;
    sum += a[i];
    type[i] = 2;
    half.insert(pair<int, int>(t[i], i));
    return true;
  }
  if (half.size() > 0) {
    pair<int, int> tmp = *half.begin();
    if (tmp.first < t[i] &&
        Time - (tmp.first + 1) / 2 + tmp.first + (t[i] + 1) / 2 <= k) {
      type[tmp.second] = 1;
      full.insert(tmp);
      half.erase(half.begin());
      Time += -(tmp.first + 1) / 2 + tmp.first + (t[i] + 1) / 2;
      sum += a[i];
      half.insert(pair<int, int>(t[i], i));
      type[i] = 2;
      return true;
    }
  }
  if (Time + t[i] <= k) {
    Time += t[i];
    sum += a[i];
    type[i] = 1;
    full.insert(pair<int, int>(t[i], i));
    return true;
  }
  return false;
}
int main() {
  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 r = 1;
  for (int l = 1; l <= n; l++) {
    r = max(r, l);
    while (r <= n && Check(l, r) == true) r++;
    res = max(res, sum);
    if (l < r) {
      if (type[l] == 1) {
        Time -= t[l];
        full.erase(full.find(pair<int, int>(t[l], l)));
      } else {
        Time -= (t[l] + 1) / 2;
        if (half.size() > 0) {
          half.erase(half.find(pair<int, int>(t[l], l)));
          if (full.size() > 0) {
            pair<int, int> tmp = *full.rbegin();
            full.erase(full.find(*full.rbegin()));
            Time += (tmp.first + 1) / 2 - tmp.first;
            type[tmp.second] = 2;
            half.insert(tmp);
          }
        }
      }
      sum -= a[l];
    }
  }
  cout << res;
}
