#include <bits/stdc++.h>
using namespace std;
const int maxn = 2 * 111111;
struct Data {
  int t, id;
  Data() {}
  Data(int _t, int _id) {
    t = _t;
    id = _id;
  }
  bool operator<(const Data& B) const {
    return (t == B.t) ? (id < B.id) : t < B.t;
  }
  bool operator==(const Data& B) const { return t == B.t && id == B.id; }
};
struct node {
  int t, v;
} a[maxn];
set<Data> S1, S2;
int nowt = 0, tot = -1, st = 0;
void Insert(int ty, int t, int id) {
  if (ty == 1) {
    S1.insert(Data(t, id));
    nowt += t;
  } else {
    S2.insert(Data(t, id));
    nowt += ((t - 1) / 2 + 1);
  }
}
void Erase(int ty, int t, int id) {
  if (ty == 1) {
    S1.erase(Data(t, id));
    nowt -= t;
  } else {
    S2.erase(Data(t, id));
    nowt -= ((t - 1) / 2 + 1);
  }
}
void ERASE(int st) {
  if (S1.find(Data(a[st].t, st)) != S1.end())
    Erase(1, a[st].t, st);
  else {
    Erase(2, a[st].t, st);
    if (S1.size() > 0) {
      Data tmp = *(--S1.end());
      Erase(1, tmp.t, tmp.id);
      Insert(2, tmp.t, tmp.id);
    }
  }
}
int n, w, k;
int main() {
  cin >> n >> w >> k;
  for (int i = 0; i < n; i++) cin >> a[i].v;
  for (int i = 0; i < n; i++) cin >> a[i].t;
  int ans = 0, ANS = 0;
  while (st != n) {
    while (nowt <= k) {
      tot++;
      if (tot >= n) break;
      if (S2.size() < w) {
        Insert(2, a[tot].t, tot);
      } else {
        Data tmp = *S2.begin();
        if (tmp.t < a[tot].t) {
          Erase(2, tmp.t, tmp.id);
          Insert(1, tmp.t, tmp.id);
          Insert(2, a[tot].t, tot);
        } else
          Insert(1, a[tot].t, tot);
      }
      if (nowt <= k)
        ans += a[tot].v;
      else {
        ERASE(tot);
        tot--;
        break;
      }
      ANS = max(ANS, ans);
    }
    ERASE(st);
    ans -= a[st].v;
    st++;
  }
  cout << ANS << endl;
}
