#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
long long arr[maxn], t[maxn];
int n, k, w;
set<pair<long long, long long> > active;
set<pair<long long, long long> > unused;
long long sum = 0;
long long tot = 0;
void add(int ind) {
  tot += arr[ind];
  if (((int)((active).size())) == w) {
    if (active.begin()->first < t[ind]) {
      unused.insert(pair<long long, long long>(active.begin()->first,
                                               active.begin()->second));
      sum -= (active.begin()->first) / 2;
      if (active.begin()->first % 2 == 1) --sum;
      sum += active.begin()->first;
      active.erase(active.begin());
      sum += t[ind] / 2;
      if (t[ind] % 2) ++sum;
      active.insert(pair<long long, long long>(t[ind], ind));
    } else {
      sum += t[ind];
      unused.insert(pair<long long, long long>(t[ind], ind));
    }
  } else {
    active.insert(pair<long long, long long>(t[ind], ind));
    sum += t[ind] / 2;
    if (t[ind] % 2) ++sum;
  }
}
void remove(int ind) {
  tot -= arr[ind];
  if (active.find(pair<long long, long long>(t[ind], ind)) != active.end()) {
    sum -= t[ind] / 2;
    if (t[ind] % 2) --sum;
    active.erase(pair<long long, long long>(t[ind], ind));
    if (((int)((unused).size())) > 0) {
      pair<long long, long long> b = *unused.rbegin();
      sum -= b.first;
      sum += b.first / 2;
      if (b.first % 2) ++sum;
      active.insert(b);
      unused.erase(b);
    }
  } else {
    sum -= t[ind];
    unused.erase(pair<long long, long long>(t[ind], ind));
    active.erase(pair<long long, long long>(t[ind], ind));
  }
}
long long getAns() {
  int l = 0, r = 0;
  long long ans = 0;
  while (r < n) {
    add(r);
    while (sum > k && l <= r) {
      remove(l);
      ++l;
    }
    ans = max(ans, tot);
    ++r;
  }
  return ans;
}
int main() {
  scanf("%d %d %d", &n, &w, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &arr[i]);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &t[i]);
  }
  cout << getAns() << "\n";
}
