#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int w, n, k;
int a[N], t[N];
int curpleasure = 0;
int curtime = 0;
multiset<pair<int, int> > top, bot;
void balance() {
  while (top.size() > w) {
    pair<int, int> p = *top.begin();
    top.erase(top.begin());
    curtime -= (p.first + 1) / 2;
    curtime += p.first;
    bot.insert(p);
  }
  while (top.size() < w && !bot.empty()) {
    pair<int, int> p = *bot.rbegin();
    bot.erase(--bot.end());
    curtime -= p.first;
    curtime += (p.first + 1) / 2;
    top.insert(p);
  }
}
int insert(int index) {
  if (top.empty() && bot.empty()) {
    curtime += (t[index] + 1) / 2;
    curpleasure += a[index];
    top.insert(make_pair(t[index], a[index]));
  } else {
    if (top.empty() || t[index] >= top.begin()->first) {
      curtime += (t[index] + 1) / 2;
      curpleasure += a[index];
      top.insert(make_pair(t[index], a[index]));
    } else {
      curtime += t[index];
      curpleasure += a[index];
      bot.insert(make_pair(t[index], a[index]));
    }
  }
  balance();
  return curtime;
}
int erase(int index) {
  pair<int, int> p(t[index], a[index]);
  multiset<pair<int, int> >::iterator it = top.find(p);
  if (it != top.end()) {
    curtime -= (p.first + 1) / 2;
    curpleasure -= p.second;
    top.erase(it);
  } else {
    it = bot.find(p);
    curtime -= p.first;
    curpleasure -= p.second;
    bot.erase(it);
  }
  balance();
  return curtime;
}
int simulate(int index) {
  int ans = insert(index);
  erase(index);
  return ans;
}
int main() {
  scanf("%d%d%d", &n, &w, &k);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  for (int i = 0; i < n; ++i) scanf("%d", t + i);
  int R = 0;
  int mxpleasure = 0;
  for (int L = 0; L < n; ++L) {
    while (R < n && simulate(R) <= k) {
      insert(R++);
    }
    mxpleasure = max(mxpleasure, curpleasure);
    if (R == L) insert(R++);
    erase(L);
  }
  printf("%d\n", mxpleasure);
}
