#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 123;
const int mod = 1e9 + 7;
int n, l, r, d[N];
struct node {
  int t, val;
  bool operator<(const node b) const {
    if (t != b.t) return t < b.t;
    return val > b.val;
  }
} a[N];
void solve() {
  cin >> n >> l >> r;
  int S = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].val;
    S += a[i].val;
  }
  for (int i = 1; i <= n; i++) cin >> a[i].t;
  sort(a + 1, a + n + 1);
  tie(l, r) = make_pair(S - r, S - l);
  fill(d + 1, d + S + 1, -1e9);
  for (int i = 1; i <= n; i++) {
    int x = a[i].val;
    for (int j = S; j >= 0; j--) {
      if (j + x <= S) {
        d[j + x] = max(d[j + x], d[j] + a[i].t * (l <= j + x && j + x <= r));
      }
    }
  }
  cout << *max_element(d, d + S + 1) << endl;
}
int main() {
  ios_base::sync_with_stdio();
  int t;
  t = 1;
  while (t--) solve();
  return 0;
}
