#include <bits/stdc++.h>
using namespace std;
multiset<int> S;
multiset<int> notS;
multiset<int>::iterator it;
int N, W, K, A[200001], T[200001], Ans;
int main(void) {
  int i, left = 1, right = 0, tot = 0, val = 0;
  scanf("%d %d %d", &N, &W, &K);
  for (i = 1; i <= N; i++) scanf("%d", &A[i]);
  for (i = 1; i <= N; i++) scanf("%d", &T[i]);
  while (1) {
    if (tot <= K) {
      Ans = max(Ans, val);
      if (right == N) break;
      right++;
      if (S.size() < W) {
        S.insert(T[right]);
        tot += (T[right] + 1) / 2;
      } else {
        it = S.begin();
        if ((*it) < T[right]) {
          tot += (T[right] + 1) / 2 - ((*it) + 1) / 2 + (*it);
          notS.insert((*it));
          S.erase(it);
          S.insert(T[right]);
        } else {
          notS.insert(T[right]);
          tot += T[right];
        }
      }
      val += A[right];
    } else {
      it = S.find(T[left]);
      if (it != S.end()) {
        S.erase(it);
        tot -= (T[left] + 1) / 2;
        if (!notS.empty()) {
          it = notS.end();
          it--;
          S.insert((*it));
          tot += (*it + 1) / 2 - (*it);
          notS.erase(it);
        }
      } else {
        it = notS.find(T[left]);
        notS.erase(it);
        tot -= T[left];
      }
      val -= A[left];
      left++;
    }
  }
  printf("%d", Ans);
  return 0;
}
