#include <bits/stdc++.h>
using namespace std;
ifstream fin(".in");
ofstream fout(".out");
int n, w, k, i, totalReduction, timeListened, pleasureSum, songNo, maxi;
int p[200005], t[200005];
multiset<int> reduced, maybe;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> w >> k;
  for (i = 1; i <= n; i++) cin >> p[i];
  for (i = 1; i <= n; i++) cin >> t[i];
  for (i = 1; i <= n; i++) {
    if (reduced.size() < w) {
      reduced.insert(t[i] / 2);
      totalReduction += t[i] / 2;
    } else if (*reduced.begin() < t[i] / 2) {
      totalReduction -= *reduced.begin();
      maybe.insert(*reduced.begin());
      reduced.erase(reduced.begin());
      reduced.insert(t[i] / 2);
      totalReduction += t[i] / 2;
    } else {
      maybe.insert(t[i] / 2);
    }
    timeListened += t[i];
    pleasureSum += p[i];
    songNo++;
    while (timeListened - totalReduction > k) {
      pleasureSum -= p[i - songNo + 1];
      if (maybe.find(t[i - songNo + 1] / 2) != maybe.end()) {
        maybe.erase(maybe.find(t[i - songNo + 1] / 2));
      } else if (reduced.find(t[i - songNo + 1] / 2) != reduced.end()) {
        totalReduction -= *reduced.find(t[i - songNo + 1] / 2);
        reduced.erase(reduced.find(t[i - songNo + 1] / 2));
        if (maybe.size()) {
          reduced.insert(*maybe.rbegin());
          totalReduction += *maybe.rbegin();
          maybe.erase(--maybe.end());
        }
      }
      timeListened -= t[i - songNo + 1];
      songNo--;
    }
    if (pleasureSum > maxi) maxi = pleasureSum;
  }
  cout << maxi;
}
