#include <bits/stdc++.h>
using namespace std;
int n, w, k, Time, Happiness, ans, a[200005], t[200005];
multiset<int> Set1, Set2;
int main() {
  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]);
  for (int l = 1, r = 1; r <= n; r++) {
    Set1.insert(t[r]);
    Time += (t[r] + 1) >> 1, Happiness += a[r];
    if (Set1.size() > w) {
      Set2.insert(*Set1.begin());
      Time += *Set1.begin() >> 1;
      Set1.erase(Set1.begin());
    }
    while (Time > k) {
      Time -= t[l];
      Happiness -= a[l];
      if (t[l] >= *Set1.begin()) {
        Time += t[l] >> 1;
        Set1.erase(Set1.find(t[l]));
        if (!Set2.empty()) {
          Set1.insert(*Set2.rbegin());
          Time -= *Set2.rbegin() >> 1;
          Set2.erase(Set2.find(*Set2.rbegin()));
        }
      } else
        Set2.erase(Set2.find(t[l]));
      l++;
    }
    ans = max(ans, Happiness);
  }
  printf("%d", ans);
  return 0;
}
