#include <bits/stdc++.h>
using namespace std;
long long n, w, k;
long long a[200010], t[200010];
struct no {
  long long t;
  long long a;
  bool friend operator<(const no& t1, const no& t2) {
    if (t1.t == t2.t) return t1.a < t2.a;
    return t1.t < t2.t;
  }
};
multiset<no> s1, s2;
signed main() {
  cin >> n >> w >> k;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= n; i++) cin >> t[i];
  long long maxx = 0, pl = 1;
  long long re = 0, ti = 0;
  for (long long i = 1; i <= w; i++) {
    if (ti + (t[i] + 1) / 2 <= k) {
      ti += (t[i] + 1) / 2;
      re += a[i];
      pl = i + 1;
      maxx = max(maxx, re);
      s1.insert({t[i], a[i]});
    } else {
      maxx = max(maxx, re);
      break;
    }
  }
  while (pl <= n) {
    no te;
    if ((long long)s1.size() < w) break;
    te = *s1.begin();
    if (te.t < t[pl] && ti + (t[pl] + 1) / 2 + te.t / 2 <= k) {
      s1.erase(s1.find(te));
      s1.insert({t[pl], a[pl]});
      s2.insert(te);
      ti += (t[pl] + 1) / 2 + te.t / 2;
      re += a[pl];
      pl++;
      maxx = max(maxx, re);
    } else if (te.t >= t[pl] && ti + t[pl] <= k) {
      ti += t[pl];
      s2.insert({t[pl], a[pl]});
      re += a[pl++];
      maxx = max(maxx, re);
    } else
      break;
  }
  for (long long st = 2; st <= n && pl <= n; st++) {
    no te;
    no tt = {t[st - 1], a[st - 1]};
    if (s1.empty() && k >= (t[st] + 1) / 2) {
      s1.insert({t[st], a[st]});
      ti = (t[st] + 1) / 2;
      re = a[st];
      pl = st + 1;
    } else if (s1.size() && s1.find(tt) != s1.end()) {
      s1.erase(s1.find(tt));
      ti -= (t[st - 1] + 1) / 2;
      re -= a[st - 1];
      if (s2.size()) {
        te = *--s2.end();
        ti -= te.t / 2;
        s2.erase(s2.find(te));
        s1.insert(te);
      }
    } else if (s2.size() && s2.find(tt) != s2.end()) {
      s2.erase(s2.find(tt));
      ti -= t[st - 1];
      re -= a[st - 1];
    }
    while (pl <= n) {
      no te = *s1.begin();
      if ((long long)s1.size() < w && (t[pl] + 1) / 2 + ti <= k) {
        ti += (t[pl] + 1) / 2;
        re += a[pl];
        maxx = max(maxx, re);
        s1.insert({t[pl], a[pl]});
        pl++;
        continue;
      }
      if ((long long)s1.size() == w && t[pl] > te.t &&
          ti + te.t / 2 + (t[pl] + 1) / 2 <= k) {
        s1.erase(s1.find(te));
        s1.insert({t[pl], a[pl]});
        s2.insert(te);
        ti = ti + te.t / 2 + (t[pl] + 1) / 2;
        re += a[pl];
        pl++;
        maxx = max(maxx, re);
        continue;
      }
      if (t[pl] <= te.t && ti + t[pl] <= k) {
        s2.insert({t[pl], a[pl]});
        re += a[pl];
        ti += t[pl];
        pl++;
        maxx = max(maxx, re);
        continue;
      }
      break;
    }
  }
  cout << maxx << endl;
}
