#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int N = 200100;
int a[N], t[N];
multiset<int> st1, st2;
multiset<int>::iterator it;
int sum = 0, nowt = 0, res = 0;
int n, m, k;
void ins(int x) {
  sum += a[x];
  if (st1.size() < m) {
    st1.insert(t[x]);
    nowt += (t[x] + 1) / 2;
  } else {
    it = st1.begin();
    if ((*it) < t[x]) {
      nowt += (t[x] + 1) / 2;
      nowt -= ((*it) + 1) / 2;
      nowt += (*it);
      st1.insert(t[x]);
      st2.insert((*it));
      st1.erase(it);
    } else {
      nowt += t[x];
      st2.insert(t[x]);
    }
  }
}
void del(int x) {
  sum -= a[x];
  if (st2.size() && st2.find(t[x]) != st2.end()) {
    nowt -= t[x];
    st2.erase(st2.find(t[x]));
  } else {
    nowt -= (t[x] + 1) / 2;
    assert(st1.find(t[x]) != st1.end());
    st1.erase(st1.find(t[x]));
    if (st2.size()) {
      it = st2.end();
      it--;
      nowt -= (*it);
      nowt += ((*it) + 1) / 2;
      st1.insert((*it));
      st2.erase(it);
    }
  }
}
int main() {
  cin >> 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]);
  }
  for (int i = 1, j = 1; i <= n; i++) {
    while (j <= n) {
      ins(j);
      if (nowt > k) {
        del(j);
        break;
      }
      j++;
    }
    if (nowt <= k) res = max(res, sum);
    if (i != j)
      del(i);
    else
      j++;
  }
  cout << res << endl;
}
