#include <bits/stdc++.h>
using namespace std;
int a[200010];
int t[200010];
int main() {
  int n, m, tt;
  scanf("%d %d %d", &n, &m, &tt);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", t + i);
  }
  set<pair<int, int> > s1, s2;
  int tot = 0, cur = 0;
  int ans = 0;
  for (int r = 0, l = 0; r < n; ++r) {
    tot += t[r];
    cur += a[r];
    int half = t[r] / 2;
    if (s1.size() < m) {
      s1.insert({half, r});
      tot -= half;
    } else {
      int low = s1.begin()->first;
      if (half > low) {
        int id = s1.begin()->second;
        s1.erase(s1.begin());
        s1.insert({half, r});
        s2.insert({-low, id});
        tot += low;
        tot -= half;
      } else {
        s2.insert({-half, r});
      }
    }
    while (l <= r && tot > tt) {
      half = t[l] / 2;
      if (s1.count({half, l}) != 0) {
        s1.erase({half, l});
        tot += half;
        if (!s2.empty()) {
          int high = -s2.begin()->first;
          int id = s2.begin()->second;
          s2.erase(s2.begin());
          s1.insert({high, id});
          tot -= high;
        }
      } else {
        s2.erase({-half, l});
      }
      tot -= t[l];
      cur -= a[l];
      ++l;
    }
    ans = max(ans, cur);
  }
  printf("%d", ans);
}
