#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 5, INF = 1e9;
int n, l, r, sum, dp[N];
pair<int, int> a[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> l >> r;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].second;
    sum += a[i].second;
    a[i].second *= -1;
  }
  int L = l, R = r;
  l = sum - R;
  r = sum - L;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first;
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= sum; i++) {
    dp[i] = -INF;
  }
  for (int i = 1; i <= n; i++) {
    a[i].second *= -1;
    for (int j = sum - a[i].second; j >= 0; j--) {
      dp[j + a[i].second] = max(
          dp[j + a[i].second],
          dp[j] + a[i].first * (l <= j + a[i].second && j + a[i].second <= r));
    }
  }
  int ans = 0;
  for (int i = 0; i <= sum; i++) {
    ans = max(ans, dp[i]);
  }
  cout << ans;
}
