#include <bits/stdc++.h>
using namespace std;
int a[200005], t[200005];
multiset<int> min_set, max_set;
int main() {
  int n, total_time, w, ans = 0, temp_ans = 0, priv_range_time = 0, curr_time;
  cin >> n >> w >> total_time;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> t[i];
  for (int start = 0, end = 0; start < n; start++) {
    curr_time = priv_range_time;
    while (end < n) {
      if (min_set.size() < w)
        curr_time += (t[end] + 1) >> 1;
      else if (t[end] > (*min_set.begin()))
        curr_time += ((t[end] + 1) >> 1) + ((*min_set.begin()) >> 1);
      else
        curr_time += t[end];
      if (curr_time > total_time) {
        ans = max(ans, temp_ans);
        break;
      }
      if (min_set.size() < w)
        min_set.insert(t[end]);
      else if (t[end] > (*min_set.begin())) {
        max_set.insert(*min_set.begin());
        min_set.erase(min_set.begin());
        min_set.insert(t[end]);
      } else
        max_set.insert(t[end]);
      temp_ans += a[end];
      priv_range_time = curr_time;
      end++;
    }
    if (end <= start) {
      end = start + 1;
      continue;
    }
    if (end == n) {
      ans = max(ans, temp_ans);
      break;
    }
    if (t[start] < (*min_set.begin())) {
      max_set.erase(max_set.find(t[start]));
      priv_range_time -= t[start];
    } else {
      min_set.erase(min_set.find(t[start]));
      priv_range_time -= (t[start] + 1) >> 1;
      if (max_set.size()) {
        auto it = max_set.end();
        it--;
        min_set.insert(*it);
        priv_range_time -= ((*it) >> 1);
        max_set.erase(it);
      }
    }
    temp_ans -= a[start];
  }
  cout << ans << endl;
  return 0;
}
