#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:64000000")
const int infi = 1e9 + 7;
const long long infl = 1e18 + 7;
int a[200500];
int t[200500];
int used[200500];
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  int n, w, k;
  cin >> n >> w >> k;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> t[i];
  set<pair<int, int> > mx, mn;
  int l = n - 1, r = n - 1;
  int ans = 0;
  int sum_a = 0;
  int sum_t = 0;
  int sum_d = 0;
  for (; l >= 0; --l) {
    if ((int)mx.size() != w) {
      mx.insert(make_pair(t[l], l));
      used[l] = 1;
      sum_d += t[l] / 2;
    } else {
      pair<int, int> a = *mx.begin();
      if (a.first < t[l]) {
        mx.erase(mx.begin());
        mn.insert(a);
        used[a.second] = 0;
        mx.insert(make_pair(t[l], l));
        used[l] = 1;
        sum_d -= a.first / 2;
        sum_d += t[l] / 2;
      } else {
        mn.insert(make_pair(t[l], l));
      }
    }
    sum_t += t[l];
    sum_a += a[l];
    while (r >= l && sum_t - sum_d > k) {
      if (used[r]) {
        mx.erase(make_pair(t[r], r));
        sum_d -= t[r] / 2;
        if (mn.size()) {
          pair<int, int> a = *(--mn.end());
          mn.erase(--mn.end());
          mx.insert(a);
          used[a.second] = 1;
          sum_d += a.first / 2;
        }
      } else {
        mn.erase(make_pair(t[r], r));
      }
      sum_t -= t[r];
      sum_a -= a[r];
      --r;
    }
    ans = max(ans, sum_a);
  }
  cout << ans;
  return 0;
}
