#include <bits/stdc++.h>
int n, w, k;
int a[(int)2e5 + 1];
int t[(int)2e5 + 1];
int ans;
std::priority_queue<int, std::vector<int>, std::greater<int> > part, dpart;
std::priority_queue<int> full, dfull;
int time_;
inline void clean(void) {
  while (part.size() && dpart.size() && part.top() == dpart.top())
    part.pop(), dpart.pop();
  while (full.size() && dfull.size() && full.top() == dfull.top())
    full.pop(), dfull.pop();
}
inline bool insert(int T) {
  clean();
  if ((time_ + ((T + 1) >> 1)) > k) return false;
  time_ += (T + 1) >> 1;
  part.push(T);
  if (part.size() - dpart.size() > w) {
    if ((time_ + (part.top() >> 1)) > k) {
      time_ -= (T + 1) >> 1;
      dpart.push(T);
      return false;
    } else {
      time_ += part.top() >> 1;
      full.push(part.top());
      dpart.push(part.top());
    }
  }
  return true;
}
inline void erase(int T) {
  clean();
  if (T < part.top()) {
    time_ -= T;
    dfull.push(T);
  } else {
    time_ -= (T + 1) >> 1;
    dpart.push(T);
    if (full.size()) {
      dfull.push(full.top());
      part.push(full.top());
      time_ -= full.top() >> 1;
    }
  }
}
int main(void) {
  scanf(" %d %d %d", &n, &w, &k);
  for (int i = 1; i <= n; ++i) {
    scanf(" %d", a + i);
  }
  for (int i = 1; i <= n; ++i) {
    scanf(" %d", t + i);
  }
  int r = 1;
  int val = 0;
  for (int l = 1; l <= n; ++l) {
    while (r <= n && insert(t[r])) val += a[r++];
    if (r > l) {
      ans = std::max(ans, val);
      val -= a[l];
      erase(t[l]);
    }
  }
  printf("%d\n", ans);
  return 0;
}
