#include <bits/stdc++.h>
using namespace std;
const int SZ = 200333;
int N, W, T;
int a[SZ], t[SZ];
struct State {
  multiset<int> L, H;
  int aSum, tSum;
  void init() {
    L.clear();
    H.clear();
    aSum = tSum = 0;
  }
  int partly(int t) { return (t + 1) / 2; }
  void insert(int a, int t) {
    if (H.size() < W) {
      H.insert(t);
      tSum += partly(t);
    } else if (*H.begin() < t) {
      int tt = *H.begin();
      H.erase(H.begin());
      tSum -= partly(tt);
      L.insert(tt);
      tSum += tt;
      H.insert(t);
      tSum += partly(t);
    } else {
      L.insert(t);
      tSum += t;
    }
    aSum += a;
  }
  void erase(int a, int t) {
    if (L.find(t) != L.end()) {
      L.erase(L.find(t));
      tSum -= t;
    } else {
      H.erase(H.find(t));
      tSum -= partly(t);
      if (L.size()) {
        int tt = *prev(L.end());
        L.erase(prev(L.end()));
        tSum -= tt;
        H.insert(tt);
        tSum += partly(tt);
      }
    }
    aSum -= a;
  }
  void print() {
    cout << "[debug] " << tSum << " :";
    for (int t : L) cout << t << " ";
    cout << "   ";
    for (int t : H) cout << t << " ";
    cout << endl;
  }
};
int main() {
  scanf("%d%d%d", &N, &W, &T);
  for (int i = 0; i < (N); i++) scanf("%d", a + i);
  for (int i = 0; i < (N); i++) scanf("%d", t + i);
  int ans = -123;
  State s;
  s.init();
  int hi = N - 1;
  for (int lo = N - 1; lo >= 0; lo--) {
    s.insert(a[lo], t[lo]);
    while (T < s.tSum) {
      s.erase(a[hi], t[hi]);
      hi--;
    }
    ans = max(ans, s.aSum);
  }
  printf("%d\n", ans);
  return 0;
}
