#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e4 + 1;
int dp[MAX];
bool cmp(pair<int, int> a, pair<int, int> b) {
  if (a.first != b.first) {
    return a.first < b.first;
  }
  return a.second > b.second;
}
void solve() {
  long long a, b, c;
  cin >> a >> b >> c;
  vector<pair<int, int>> x(a);
  int l, r;
  int sum = 0;
  for (int i = 0; i < a; ++i) {
    cin >> x[i].second;
    sum += x[i].second;
  }
  int buf = sum - c;
  c = sum - b;
  b = buf;
  for (int i = 0; i < a; ++i) {
    cin >> x[i].first;
  }
  sort(x.begin(), x.end(), cmp);
  int res = 0;
  for (int i = 0; i <= c; ++i) {
    dp[i] = -1e9;
  }
  dp[0] = 0;
  for (int i = 0; i < a; ++i) {
    for (int j = c; j >= x[i].second; --j) {
      dp[j] = max(dp[j], dp[j - x[i].second] + x[i].first * (j <= c && j >= b));
    }
  }
  for (int i = 0; i <= c; ++i) {
    res = max(res, dp[i]);
  }
  cout << res << endl;
}
int main() {
  cout.setf(ios::fixed);
  cout.precision(9);
  solve();
  return 0;
}
