#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
priority_queue<pair<int, int> > q2;
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    q1;
int a[maxn], t[maxn], vis[maxn], w, d, ans, m1, m2;
long long k, s1, s2;
void add(int x) {
  pair<int, int> u, v;
  d += a[x];
  if (m1 < w) {
    q1.push(pair<int, int>(t[x], x));
    s1 += (t[x] + 1) / 2;
    vis[x] = 1;
    m1++;
  } else {
    q2.push(pair<int, int>(t[x], x));
    vis[x] = 2;
    s2 += t[x];
    m2++;
    while (vis[(q2.top()).second] == 3) q2.pop();
    while (vis[(q1.top()).second] == 3) q1.pop();
    if ((q2.top()).first > (q1.top()).first) {
      u = q2.top();
      q2.pop();
      v = q1.top();
      q1.pop();
      q1.push(u);
      q2.push(v);
      s1 += (t[u.second] + 1) / 2 - (t[v.second] + 1) / 2;
      s2 += t[v.second] - t[u.second];
      vis[u.second] = 1;
      vis[v.second] = 2;
    }
  }
}
void del(int x) {
  if (vis[x] == 1) {
    s1 -= (t[x] + 1) / 2;
    if (m2) {
      while (vis[(q2.top()).second] == 3) q2.pop();
      pair<int, int> u;
      u = q2.top();
      q2.pop();
      m2--;
      s2 -= t[u.second];
      q1.push(u);
      s1 += (t[u.second] + 1) / 2;
      vis[u.second] = 1;
    } else
      m1--;
  }
  if (vis[x] == 2) {
    m2--;
    s2 -= t[x];
  }
  vis[x] = 3;
  d -= a[x];
}
int main() {
  int n, i, j;
  scanf("%d%d%I64d", &n, &w, &k);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 0; i < n; i++) scanf("%d", &t[i]);
  j = 0;
  for (i = 0; i < n; i++) {
    add(i);
    while (s1 + s2 > k && j <= i) del(j++);
    ans = max(ans, d);
  }
  printf("%d\n", ans);
  return 0;
}
