#include <bits/stdc++.h>
using namespace std;
set<pair<int, int> > half, full;
const int N = 2e5 + 100;
int a[N], t[N];
int main() {
  int n, w, k, ans, curt, j, p;
  cin >> n >> w >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> t[i];
  j = ans = curt = p = 0;
  for (int i = 0; i < n;) {
    while (i < n && curt < k) {
      if (half.size() < w) {
        curt += (t[i] + 1) / 2;
        half.insert({t[i], i});
      } else if ((*half.begin()).first < t[i]) {
        curt -= ((*half.begin()).first + 1) / 2;
        curt += (*half.begin()).first;
        full.insert(*half.begin());
        half.erase(*half.begin());
        curt += (t[i] + 1) / 2;
        half.insert({t[i], i});
      } else {
        curt += t[i];
        full.insert({t[i], i});
      }
      p += a[i++];
      if (curt <= k) ans = max(ans, p);
    }
    while (j < i && curt >= k) {
      if (half.count({t[j], j})) {
        curt -= (t[j] + 1) / 2;
        half.erase({t[j], j});
        if (full.size()) {
          pair<int, int> top = *full.rbegin();
          curt -= top.first;
          curt += (top.first + 1) / 2;
          half.insert(top);
          full.erase(top);
        }
      } else {
        curt -= t[j];
        full.erase({t[j], j});
      }
      p -= a[j++];
      if (curt <= k) ans = max(ans, p);
    }
  }
  cout << ans;
  return 0;
}
