#include <bits/stdc++.h>
using namespace std;
int a[200010], t[200010];
bool inHalf[200010];
set<pair<int, int> > half, normal;
int main() {
  int n, w, k;
  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);
  long long nowSum = 0, sumP = 0;
  long long ans = 0;
  int pos = 0;
  for (int i = 1; i <= n; i++) {
    if ((t[i] + 1) / 2 > k) {
      nowSum = 0;
      sumP = 0;
      if (half.size())
        for (auto it = half.begin(); it != half.end(); it++)
          inHalf[it->second] = false;
      half.clear();
      normal.clear();
      pos = i;
    } else {
      while (pos < n && (int)half.size() < w &&
             nowSum + (t[pos + 1] + 1) / 2 <= k) {
        pos++;
        inHalf[pos] = true;
        nowSum += (t[pos] + 1) / 2;
        sumP += a[pos];
        half.insert(pair<int, int>(t[pos], pos));
      }
      while (pos < n && nowSum <= k) {
        long long nxtSum = nowSum;
        if (!half.empty() &&
            (half.begin()->first + 1) / 2 < (t[pos + 1] + 1) / 2) {
          nxtSum -= (half.begin()->first + 1) / 2;
          nxtSum += (t[pos + 1] + 1) / 2 + half.begin()->first;
          if (nxtSum <= k) {
            inHalf[half.begin()->second] = false;
            inHalf[pos + 1] = true;
            normal.insert(*half.begin());
            half.erase(half.begin());
            half.insert(pair<int, int>(t[pos + 1], pos + 1));
          }
        } else {
          nxtSum += t[pos + 1];
          if (nxtSum <= k) {
            normal.insert(pair<int, int>(t[pos + 1], pos + 1));
          }
        }
        if (nxtSum <= k) {
          nowSum = nxtSum;
          ++pos;
          sumP += a[pos];
        } else
          break;
      }
    }
    ans = max(ans, sumP);
    if (inHalf[i]) {
      nowSum -= (t[i] + 1) / 2;
      half.erase(pair<int, int>(t[i], i));
      if (!normal.empty()) {
        auto it = normal.end();
        it--;
        half.insert(*it);
        inHalf[it->second] = true;
        nowSum -= (t[it->second]) / 2;
        normal.erase(it);
      }
      inHalf[i] = false;
    } else {
      nowSum -= t[i];
      normal.erase(pair<int, int>(t[i], i));
    }
    sumP -= a[i];
  }
  printf("%lld\n", ans);
  return 0;
}
