#include <bits/stdc++.h>
using namespace std;
int pleasure[200010];
int t[200010];
class compare {
 public:
  bool operator()(pair<int, int> a, pair<int, int> b) {
    if (a.first != b.first) {
      return a.first < b.first;
    }
    return a.second > b.second;
  }
};
class compare2 {
 public:
  bool operator()(pair<int, int> a, pair<int, int> b) {
    if (a.first != b.first) {
      return a.first > b.first;
    }
    return a.second > b.second;
  }
};
int main(void) {
  int n, w, k;
  priority_queue<pair<int, int>, vector<pair<int, int> >, compare> unused;
  priority_queue<pair<int, int>, vector<pair<int, int> >, compare2> used;
  scanf("%d", &n);
  scanf("%d", &w);
  scanf("%d", &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &pleasure[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &t[i]);
  }
  long long maxP = 0;
  long long curP = 0;
  int st_idx = 0;
  int t_left = k;
  int partial = w;
  map<int, int> is_inside;
  for (int i = 0; i < n; i++) {
    curP += pleasure[i];
    t_left -= t[i];
    unused.push(pair<int, int>(t[i], i));
    while (!unused.empty()) {
      pair<int, int> top = unused.top();
      if (top.second < st_idx) {
        unused.pop();
      } else
        break;
    }
    while (!used.empty()) {
      pair<int, int> top = used.top();
      if (top.second < st_idx) {
        used.pop();
      } else
        break;
    }
    if (partial == 0) {
      while (!unused.empty()) {
        pair<int, int> top_unused = unused.top();
        pair<int, int> top_used = used.top();
        if (top_unused.first > top_used.first &&
            is_inside[top_used.second] == 1) {
          unused.pop();
          used.pop();
          unused.push(top_used);
          used.push(top_unused);
          t_left -= (top_used.first) / 2;
          t_left += (top_unused.first) / 2;
          is_inside[top_used.second] = 0;
          is_inside[top_unused.second] = 1;
        } else
          break;
      }
    } else {
      while (partial && !unused.empty()) {
        pair<int, int> top = unused.top();
        unused.pop();
        if (top.second < st_idx) continue;
        partial--;
        used.push(top);
        t_left += top.first / 2;
        is_inside[top.second] = 1;
      }
    }
    while (t_left < 0) {
      curP -= pleasure[st_idx];
      if (is_inside[st_idx] == 1) {
        t_left += (t[st_idx] + 1) / 2;
        partial++;
        while (partial && !unused.empty()) {
          pair<int, int> top = unused.top();
          unused.pop();
          if (top.second < st_idx) continue;
          used.push(top);
          t_left += (top.first) / 2;
          is_inside[top.second] = 1;
          partial--;
        }
      } else {
        t_left += t[st_idx];
      }
      st_idx++;
    }
    maxP = max(maxP, curP);
  }
  cout << maxP << endl;
  return 0;
}
