#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <typename T>
constexpr int infValue =
    std::is_same<T, int>::value ? 2000000007 : 8600000000000000007ll;
template <typename T>
constexpr int maxValue =
    std::is_same<T, int>::value ? 1000000007 : 1000000000000000001ll;
const int INF = infValue<int>;
const int MOD = 1000000007ll;
const double EPS = 1e-6;
const int MAX = maxValue<int>;
int n, w, k;
int a[200101], t[200101];
set<pair<int, int>> q;
set<pair<int, int>, greater<pair<int, int>>> f;
int answ;
int main(void) {
  scanf("%d %d %d", &n, &w, &k);
  for (register int i = 0; i < n; ++i) scanf("%d", a + i);
  for (register int i = 0; i < n; ++i) scanf("%d", t + i);
  int i = 0, j = 0, s = 0;
  while (i < n) {
    while (j < n) {
      if (q.size() == w) {
        if (q.begin()->first > t[j]) {
          if (t[j] > k) break;
          k -= t[j];
          s += a[j];
          f.insert({t[j], j});
        } else {
          int v = -(q.begin()->first + 1 >> 1) + q.begin()->first +
                  ((t[j] + 1) >> 1);
          if (v > k) break;
          k -= v;
          f.insert(*q.begin());
          q.erase(q.begin());
          q.insert({t[j], j});
          s += a[j];
        }
      } else {
        if (k < t[j] + 1 >> 1) break;
        q.insert({t[j], j}), s += a[j], k -= t[j] + 1 >> 1;
      }
      ++j;
    }
    answ = max(answ, s);
    if (q.count({t[i], i})) {
      q.erase({t[i], i});
      s -= a[i];
      k += t[i] + 1 >> 1;
      if (!f.empty()) {
        int v = (f.begin()->first + 1 >> 1) - f.begin()->first;
        q.insert(*f.begin());
        f.erase(f.begin());
        k -= v;
      }
    } else if (i < j) {
      k += t[i];
      s -= a[i];
      f.erase({t[i], i});
    }
    ++i;
  }
  printf("%d\n", answ);
  return 0;
}
