#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, w, k;
int a[N], t[N];
int d[N];
bool in[N];
struct Sol {
  set<pair<int, int> > big;
  set<pair<int, int> > small;
  int z = 0;
  void add(int i) {
    if (small.empty() || t[i] > small.rbegin()->first) {
      big.insert(make_pair(t[i], i));
      z += (t[i] + 1) / 2;
    } else {
      small.insert(make_pair(t[i], i));
      z += t[i];
    }
    while (big.size() > w) {
      auto tt = *big.begin();
      big.erase(big.begin());
      z -= (tt.first + 1) / 2;
      small.insert(tt);
      z += tt.first;
    }
  }
  void erase(int i) {
    if (small.count(make_pair(t[i], i))) {
      small.erase(make_pair(t[i], i));
      z -= t[i];
    } else {
      big.erase(make_pair(t[i], i));
      z -= (t[i] + 1) / 2;
    }
    while (big.size() < w) {
      if (small.empty()) break;
      auto tt = *small.rbegin();
      small.erase(--small.end());
      z -= tt.first;
      big.insert(tt);
      z += (tt.first + 1) / 2;
    }
  }
  int get() { return z; }
} sol;
int main() {
  scanf("%d%d%d", &n, &w, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  for (int i = 0; i < n; ++i) d[i] = (i == 0 ? 0 : d[i - 1]) + a[i];
  for (int i = 0; i < n; ++i) {
    scanf("%d", t + i);
  }
  int ans = 0;
  int j = 0;
  for (int i = 0; i < n; ++i) {
    for (; j < n; ++j) {
      sol.add(j);
      in[j] = 1;
      if (sol.get() > k) {
        sol.erase(j);
        in[j] = 0;
        break;
      }
    }
    if (sol.get() <= k) {
      ans = max(ans, d[j - 1] - (i == 0 ? 0 : d[i - 1]));
    }
    if (in[i]) {
      sol.erase(i);
    }
  }
  printf("%d\n", ans);
  return 0;
}
