#include <bits/stdc++.h>
using namespace std;
const int N = 234567;
int n, w, k;
struct Song {
  int pleasure;
  int length;
  int id;
  Song() {}
  inline bool operator<(const Song &other) const {
    if (length != other.length) {
      return length < other.length;
    }
    return id < other.id;
  }
};
Song a[N];
struct MagicSet {
  multiset<Song> full;
  multiset<Song> partial;
  int pleasure, length;
  MagicSet() {
    pleasure = 0;
    length = 0;
    full.clear();
    partial.clear();
  }
  void optimize() {
    while (!full.empty() && partial.size() < w) {
      auto it = full.end();
      it--;
      length -= it->length;
      length += (it->length + 1) / 2;
      partial.insert(*it);
      full.erase(it);
    }
    while (true) {
      if (full.empty() || partial.empty()) {
        break;
      }
      auto it = full.end();
      it--;
      auto itt = partial.begin();
      if (it->length > itt->length) {
        length -= it->length;
        length += (it->length + 1) / 2;
        length -= (itt->length + 1) / 2;
        length += itt->length;
        partial.insert(*it);
        full.insert(*itt);
        partial.erase(itt);
        full.erase(it);
      } else {
        break;
      }
    }
  }
  inline void insert(const Song &x) {
    pleasure += x.pleasure;
    length += x.length;
    full.insert(x);
    optimize();
  }
  inline void erase(const Song &x) {
    pleasure -= x.pleasure;
    if (full.find(x) != full.end()) {
      full.erase(full.find(x));
      length -= x.length;
    } else {
      partial.erase(partial.find(x));
      length -= (x.length + 1) / 2;
    }
    optimize();
  }
};
int main() {
  scanf("%d%d%d", &n, &w, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i].pleasure);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i].length);
    a[i].id = i;
  }
  int ans = 0;
  MagicSet s;
  int low = 0;
  for (int i = 0; i < n; i++) {
    s.insert(a[i]);
    while (low <= i && s.length > k) {
      s.erase(a[low]);
      low++;
    }
    ans = max(ans, s.pleasure);
  }
  printf("%d\n", ans);
  return 0;
}
