#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 5;
long long n, sum, sum2, w, k, a[maxn], ti[maxn], ans;
set<pair<long long, long long>> s;
set<pair<long long, long long>, greater<pair<long long, long long>>> s1;
bool mrk[maxn];
void f16_62() {
  while (s1.size()) {
    long long sz = s.size();
    if (sz < w) {
      pair<long long, long long> p = (*s1.begin());
      s1.erase(p);
      sum2 = sum2 - ti[p.second];
      s.insert(p);
      mrk[p.second] = 1;
      sum2 += (ti[p.second] + 1ll) / 2ll;
      continue;
    }
    pair<long long, long long> p = (*s1.begin());
    pair<long long, long long> p2 = (*s.begin());
    if (p2.first < p.first) {
      s1.erase(p);
      s.erase(p2);
      sum2 = sum2 - (((ti[p2.second] + 1ll) / 2ll) + ti[p.second]);
      sum2 = sum2 + (ti[p2.second] + ((ti[p.second] + 1ll) / 2ll));
      s1.insert(p2);
      s.insert(p);
      mrk[p.second] = 1;
      mrk[p2.second] = 0;
    } else
      break;
  }
}
void aDd(long long i) {
  sum += a[i];
  sum2 += ti[i];
  long long x = ti[i] / 2ll;
  pair<long long, long long> p = {x, i};
  s1.insert(p);
  if (i > n)
    cout << "i"
         << " : " << i << "\n";
  if (i < 0)
    cout << "i"
         << " : " << i << "\n";
  f16_62();
  if (sum2 <= k) ans = max(ans, sum);
}
void dLt(long long i) {
  long long x = ti[i] / 2ll;
  pair<long long, long long> p = {x, i};
  sum -= a[i];
  if (mrk[i]) {
    s.erase(p);
    sum2 -= ((ti[i] + 1ll) / 2ll);
    mrk[i] = 0;
  } else {
    s1.erase(p);
    sum2 -= ti[i];
  }
  f16_62();
  if (sum2 <= k) ans = max(ans, sum);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> w >> k;
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n; i++) cin >> ti[i];
  aDd(0);
  long long p1 = 0, p2 = 1;
  while (p1 < n) {
    if (sum2 > k) {
      dLt(p1);
      p1++;
      continue;
    }
    ans = max(ans, sum);
    if (p1 == p2) {
      aDd(p1);
      p2++;
      continue;
    }
    while ((p2 < n) && (sum2 <= k)) {
      ans = max(ans, sum);
      aDd(p2);
      p2++;
    }
    dLt(p1);
    p1++;
  }
  cout << ans << endl;
}
