#include <bits/stdc++.h>
using int_t = long long int;
constexpr int_t inf = 1000000000000000000;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int_t n;
  int_t w;
  int_t k;
  std::cin >> n >> w >> k;
  std::vector<int_t> a(n);
  for (int_t& ai : a) {
    std::cin >> ai;
  }
  std::vector<int_t> t(n);
  for (int_t& ti : t) {
    std::cin >> ti;
  }
  int_t result = 0;
  int_t left = 0;
  int_t right = 0;
  int_t time = 0;
  int_t pleasure = 0;
  std::set<std::pair<int_t, int_t>> part;
  std::set<std::pair<int_t, int_t>> full;
  while (right < n) {
    while (time <= k && right < n) {
      if (part.size() < w) {
        part.emplace(t[right], right);
        time += (t[right] + 1) / 2;
      } else if (part.begin()->first < t[right]) {
        time -= (part.begin()->first + 1) / 2;
        time += part.begin()->first;
        full.emplace(*part.begin());
        part.erase(part.begin());
        part.emplace(t[right], right);
        time += (t[right] + 1) / 2;
      } else {
        full.emplace(t[right], right);
        time += t[right];
      }
      pleasure += a[right];
      if (time <= k) {
        result = std::max(result, pleasure);
      }
      ++right;
    }
    while (time > k) {
      auto iter = part.find(std::make_pair(t[left], left));
      if (iter != part.end()) {
        time -= (t[left] + 1) / 2;
        part.erase(iter);
        if (!full.empty()) {
          time -= full.rbegin()->first;
          time += (full.rbegin()->first + 1) / 2;
          part.emplace(*full.rbegin());
          full.erase(std::prev(full.end()));
        }
      } else {
        time -= t[left];
        full.erase(std::make_pair(t[left], left));
      }
      pleasure -= a[left];
      if (time <= k) {
        result = std::max(result, pleasure);
      }
      ++left;
    }
  }
  std::cout << result << '\n';
  return 0;
}
