#include <bits/stdc++.h>
using namespace std;
struct str1 {
  int x, y;
  inline bool operator<(const str1 t) const {
    if (x != t.x)
      return x < t.x;
    else
      return y < t.y;
  }
};
set<str1> S1;
struct str2 {
  int x, y;
  inline bool operator<(const str2 t) const {
    if (x != t.x)
      return x > t.x;
    else
      return y > t.y;
  }
};
set<str2> S2;
inline int fastscanf() {
  int t = 0;
  char c = getchar();
  while (!((c > 47) && (c < 58))) c = getchar();
  while ((c > 47) && (c < 58)) t = t * 10 + c - 48, c = getchar();
  return t;
}
int u[300000], v[300000];
int i, k, l, m, n, r, s, t;
str1 tmp_;
str2 tmp;
inline void del(int i) {
  if ((*S1.find((str1){u[i], i})).y) {
    r = r - (u[i] + 1) / 2;
    S1.erase((str1){u[i], i});
    if (!S2.empty()) {
      tmp = *S2.begin();
      r = r - tmp.x + (tmp.x + 1) / 2;
      S1.insert((str1){tmp.x, tmp.y});
      S2.erase(tmp);
    }
    t = t - v[i];
  } else if ((*S2.find((str2){u[i], i})).y) {
    r = r - u[i];
    S2.erase((str2){u[i], i});
    t = t - v[i];
  }
  return;
}
int main() {
  n = fastscanf(), k = fastscanf(), m = fastscanf();
  for (i = 1; i <= n; i++) v[i] = fastscanf();
  for (i = 1; i <= n; i++) u[i] = fastscanf();
  for (i = 1, l = 0; i <= n; i++) {
    for (; l <= n;) {
      if (r + (u[l] + 1) / 2 > m) break;
      if (S1.size() < k) {
        r = r + (u[l] + 1) / 2;
        S1.insert((str1){u[l], l});
        t = t + v[l];
        l++;
      } else {
        r = r + u[l];
        S2.insert((str2){u[l], l});
        tmp_ = *S1.begin(), tmp = *S2.begin();
        if (tmp.x > tmp_.x) {
          S1.erase(tmp_), S2.erase(tmp);
          swap(tmp_.x, tmp.x), swap(tmp_.y, tmp.y);
          S1.insert(tmp_), S2.insert(tmp);
          r = r - tmp_.x + (tmp_.x + 1) / 2;
          r = r + tmp.x - (tmp.x + 1) / 2;
        }
        t = t + v[l];
        if (r > m) {
          del(l);
          break;
        }
        l++;
      }
    }
    s = max(s, t);
    del(i);
  }
  printf("%d", s);
  return 0;
}
