#include <bits/stdc++.h>
using namespace std;
int n, w, k, a[200005], t[200005];
set<pair<int, int> > s, s1;
int ds = 0, dd[200005];
void lam() {
  int i = 1, j = 1;
  int T = 0, res = 0;
  while (i <= n) {
    j = max(j, i);
    while (j <= n) {
      while (!s.empty() && w) {
        pair<int, int> x = *s.rbegin();
        s.erase(x);
        dd[x.second] = 1;
        s1.insert(pair<int, int>((x.first + 1) / 2, x.second));
        T = T - x.first + (x.first + 1) / 2;
        --w;
      }
      if (w && T + (t[j] + 1) / 2 <= k) {
        s1.insert(pair<int, int>((t[j] + 1) / 2, j));
        T += (t[j] + 1) / 2;
        res += a[j];
        dd[j] = 1;
        ++j;
        --w;
        continue;
      }
      pair<int, int> x = *s1.begin();
      if (t[x.second] < t[j] &&
          T - x.first + t[x.second] + (t[j] + 1) / 2 <= k) {
        s1.erase(x);
        s1.insert(pair<int, int>((t[j] + 1) / 2, j));
        s.insert(pair<int, int>(t[x.second], x.second));
        dd[x.second] = 0;
        dd[j] = 1;
        T = T - x.first + t[x.second] + (t[j] + 1) / 2;
        res += a[j];
        ++j;
        continue;
      }
      if (T + t[j] <= k) {
        s.insert(pair<int, int>(t[j], j));
        dd[j] = 0;
        T += t[j];
        res += a[j];
        ++j;
        continue;
      }
      break;
    }
    ds = max(ds, res);
    res -= a[i];
    if (dd[i] == 0) {
      s.erase(pair<int, int>(t[i], i));
      T -= t[i];
    } else {
      s.erase(pair<int, int>((t[i] + 1) / 2, i));
      T -= (t[i] + 1) / 2;
      ++w;
    }
    ++i;
  }
  cout << ds;
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(0);
  cin >> n >> w >> k;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) cin >> t[i];
  lam();
}
