#include <bits/stdc++.h>
using namespace std;
set<pair<int, int> > stw, st;
int n, m, k;
int A[200003], T[200003];
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &A[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &T[i]);
  int res = 0, sum = 0;
  int tuse = 0;
  int kir = 1;
  for (int i = 1; i <= n; i++) {
    if (stw.size() < m) {
      stw.insert({T[i], i});
      tuse += (T[i] + 1) / 2;
      sum += A[i];
    } else {
      st.insert({T[i], i});
      tuse += T[i];
      sum += A[i];
      auto it = st.end();
      --it;
      auto jt = stw.begin();
      if (*it > *jt) {
        tuse = tuse - (*it).first + ((*it).first + 1) / 2;
        tuse = tuse - ((*jt).first + 1) / 2 + (*jt).first;
        pair<int, int> temp1 = *it, temp2 = *jt;
        st.erase(temp1);
        stw.erase(temp2);
        stw.insert(temp1);
        st.insert(temp2);
      }
    }
    while (tuse > k) {
      sum -= A[kir];
      if (st.find({T[kir], kir}) != st.end()) {
        tuse -= T[kir];
        st.erase({T[kir], kir});
      } else {
        tuse -= (T[kir] + 1) / 2;
        stw.erase({T[kir], kir});
        if (st.size()) {
          auto it = st.end();
          it--;
          tuse = tuse - (*it).first + ((*it).first + 1) / 2;
          pair<int, int> temp = *it;
          st.erase(temp);
          stw.insert(temp);
        }
      }
      kir++;
    }
    res = max(sum, res);
  }
  printf("%d\n", res);
}
