#include <bits/stdc++.h>
using namespace std;
inline int rd() {
  int x = 0, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return x * f;
}
const int MAXN = 2e5 + 10;
multiset<long long> S, ano;
long long N, W, K;
long long a[MAXN], t[MAXN];
int inset[MAXN];
long long sum, time_can_del, total_time, ans;
void Insert(long long T) {
  T = T / 2;
  if (S.size() < W)
    S.insert(T), time_can_del += T;
  else if (*S.begin() < T) {
    time_can_del -= *S.begin();
    ano.insert(*S.begin());
    S.erase(S.begin());
    S.insert(T);
    time_can_del += T;
  } else {
    ano.insert(T);
  }
}
void Remove(long long T) {
  T = T / 2;
  multiset<long long>::iterator it = S.find(T), ano_it;
  if (it != S.end()) {
    S.erase(it);
    time_can_del -= T;
  } else {
    it = ano.find(T);
    if (it != ano.end()) {
      ano.erase(it);
    } else {
      exit(12);
    }
  }
  while (S.size() < W && ano.size()) {
    ano_it = ano.end();
    --ano_it;
    S.insert(*ano_it);
    time_can_del += *ano_it;
    ano.erase(ano_it);
  }
}
int main() {
  N = rd(), W = rd(), K = rd();
  for (int i = 1; i <= N; ++i) a[i] = rd();
  for (int i = 1; i <= N; ++i) t[i] = rd();
  int l = 1, r = 0;
  for (; l <= N; ++l) {
    if (l - 1) {
      Remove(t[l - 1]);
      total_time -= t[l - 1];
      sum -= a[l - 1];
    }
    while (r <= N && total_time - time_can_del <= K) {
      ans = max(ans, sum);
      if (r == N) break;
      ++r;
      total_time += t[r];
      sum += a[r];
      Insert(t[r]);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
