#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7;
const long long mod = 1000000007;
const long long N = 400001;
void solve() {
  long long n, w, k;
  cin >> n >> w >> k;
  vector<long long> a(n), t(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < n; i++) {
    cin >> t[i];
  }
  long long j = 0;
  long long nt = 0;
  long long mans = 0;
  long long nans = 0;
  multiset<long long> songs;
  multiset<long long> skipsongs;
  map<long long, long long> so, sk;
  for (long long i = 0; i < n; i++) {
    while (j < n && nt < k) {
      if (nt + t[j] <= k) {
        songs.insert(t[j]);
        so[t[j]]++;
        if (skipsongs.size() < w) {
          skipsongs.insert(t[j]);
          sk[t[j]]++;
          nt += ((t[j] + 1) / 2);
          nans += a[j];
          j++;
          continue;
        } else {
          if (*skipsongs.begin() < t[j]) {
            sk[*skipsongs.begin()]--;
            nt -= (*skipsongs.begin() + 1) / 2;
            nt += *skipsongs.begin();
            skipsongs.erase(skipsongs.begin());
            skipsongs.insert(t[j]);
            sk[t[j]]++;
            nt += ((t[j] + 1) / 2);
            nans += a[j];
            j++;
            continue;
          } else {
            nt += t[j];
            nans += a[j];
            j++;
            continue;
          }
        }
      } else if (nt + ((t[j] + 1) / 2) <= k) {
        if (skipsongs.size() < w) {
          songs.insert(t[j]);
          so[t[j]]++;
          skipsongs.insert(t[j]);
          sk[t[j]]++;
          nt += ((t[j] + 1) / 2);
          nans += a[j];
          j++;
          continue;
        } else {
          int ms = *skipsongs.begin();
          int dnt = nt;
          dnt -= (ms + 1) / 2;
          dnt += ms;
          dnt += ((t[j] + 1) / 2);
          if (ms < t[j] && dnt <= k) {
            songs.insert(t[j]);
            so[t[j]]++;
            sk[*skipsongs.begin()]--;
            nt -= (*skipsongs.begin() + 1) / 2;
            nt += *skipsongs.begin();
            skipsongs.erase(skipsongs.begin());
            skipsongs.insert(t[j]);
            sk[t[j]]++;
            nt += ((t[j] + 1) / 2);
            nans += a[j];
            j++;
            continue;
          } else
            break;
        }
      } else
        break;
    }
    if (i == j) {
      j++;
      continue;
    }
    mans = max(mans, nans);
    if (skipsongs.find(t[i]) != skipsongs.end()) {
      skipsongs.erase(skipsongs.find(t[i]));
      songs.erase(songs.find(t[i]));
      sk[t[i]]--;
      so[t[i]]--;
      nt -= (t[i] + 1) / 2;
      nans -= a[i];
      if (songs.size() != skipsongs.size()) {
        auto it = songs.find(*skipsongs.begin());
        if (so[*it] == sk[*it]) it--;
        sk[*it]++;
        skipsongs.insert(*it);
        nt -= *it;
        nt += (*it + 1) / 2;
      }
    } else {
      songs.erase(songs.find(t[i]));
      so[t[i]]--;
      nt -= t[i];
      nans -= a[i];
    }
  }
  cout << mans << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
