#include <bits/stdc++.h>
using namespace std;
struct Node {
  int a, t, no;
} song[200005], temp1, temp2;
struct cmp1 {
  bool operator()(Node x1, Node x2) { return x1.t < x2.t; }
};
struct cmp2 {
  bool operator()(Node x1, Node x2) { return x1.t > x2.t; }
};
priority_queue<Node, vector<Node>, cmp2> q1;
priority_queue<Node, vector<Node>, cmp1> q2;
int life[200005];
int main() {
  int ans = 0, now = 0;
  int n, w, k, nums = 0;
  int l = 0, r = 0;
  cin >> n >> w >> k;
  for (int i = 1; i <= n; i++) scanf("%d", &(song[i].a));
  for (int i = 1; i <= n; i++) scanf("%d", &(song[i].t));
  for (int i = 1; i <= n; i++) song[i].no = i;
  while (r + 1 <= n) {
    if (life[l]) {
      if (life[l] == 1) {
        w++;
        k += (song[l].t + 1) / 2;
        if (nums) {
          while (temp2 = q2.top(), life[temp2.no] == 0) {
            q2.pop();
          }
          q2.pop();
          q1.push(temp2);
          life[temp2.no] = 1;
          k += temp2.t / 2;
          w--;
          nums--;
        }
      }
      if (life[l] == 2) {
        k += song[l].t;
        nums--;
      }
      now -= song[l].a;
      life[l] = 0;
    }
    l++;
    while (r + 1 <= n) {
      if (w) {
        if ((song[r + 1].t + 1) / 2 <= k) {
          r++;
          k -= (song[r].t + 1) / 2;
          w--;
          now += song[r].a;
          q1.push(song[r]);
          life[r] = 1;
        } else
          break;
      } else {
        while (temp1 = q1.top(), life[temp1.no] == 0) {
          q1.pop();
        }
        if (song[r + 1].t > temp1.t) {
          if ((song[r + 1].t + 1) / 2 + temp1.t - (temp1.t + 1) / 2 <= k) {
            r++;
            now += song[r].a;
            k -= (song[r].t + 1) / 2 + temp1.t - (temp1.t + 1) / 2;
            nums++;
            q2.push(temp1);
            q1.pop();
            life[temp1.no] = 2;
            life[r] = 1;
            q1.push(song[r]);
          } else
            break;
        } else {
          if (song[r + 1].t <= k) {
            r++;
            k -= song[r].t;
            now += song[r].a;
            life[r] = 2;
            nums++;
            q2.push(song[r]);
          } else
            break;
        }
      }
    }
    ans = max(ans, now);
    r = max(r, l);
  }
  cout << ans << endl;
  return 0;
}
