#include <bits/stdc++.h>
using namespace std;
constexpr int N = 2e5 + 10;
long long n, w, k, happy[N], nice, t[N], mytime, ans;
bool in[N];
pair<int, int> lowest;
set<pair<int, int>> st;
queue<int> q;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> w >> k;
  for (int i = 0; i < n; i++) cin >> happy[i];
  for (int i = 0; i < n; i++) cin >> t[i];
  for (int i = n - 1; ~i; i--) {
    st.insert({t[i], -i});
    if ((int)st.size() == w) {
      lowest = *st.begin();
      mytime += (t[i] + 1) / 2;
      in[i] = true;
    } else if ((int)st.size() > w) {
      if (t[i] >= lowest.first) {
        in[-lowest.second] = false;
        mytime += (t[i] + 1) / 2;
        mytime -= (lowest.first + 1) / 2;
        mytime += lowest.first;
        lowest = *st.upper_bound(lowest);
        in[i] = true;
      } else
        mytime += t[i];
    } else {
      in[i] = true;
      mytime += (t[i] + 1) / 2;
    }
    nice += happy[i];
    q.push(i);
    while (mytime > k) {
      nice -= happy[q.front()];
      if (in[q.front()]) {
        mytime -= (t[q.front()] + 1) / 2;
        in[q.front()] = false;
        st.erase({t[q.front()], -q.front()});
        if ((int)st.size() >= w) {
          lowest = *(--st.lower_bound(lowest));
          in[-lowest.second] = true;
          mytime -= lowest.first;
          mytime += (lowest.first + 1) / 2;
        }
      } else {
        mytime -= t[q.front()];
        st.erase({t[q.front()], -q.front()});
      }
      q.pop();
    }
    ans = max(ans, nice);
  }
  cout << ans << '\n';
  return 0;
}
