#include <bits/stdc++.h>
using namespace std;
bool home = 1;
signed realMain();
signed main() {
  home = 0;
  if (home) {
    freopen("input", "r", stdin);
  } else {
    ios::sync_with_stdio(0);
    cin.tie(0);
  }
  realMain();
}
struct T {
  long long type, len;
};
bool operator<(T a, T b) {
  if (a.type != b.type) return a.type < b.type;
  return a.len > b.len;
}
const long long N = (long long)1e4 + 7, INF = (long long)1e9;
long long n, l, r, s, dp[N];
T a[N];
signed realMain() {
  cin >> n >> l >> r;
  for (long long i = 1; i <= n; i++) cin >> a[i].len;
  for (long long i = 1; i <= n; i++) cin >> a[i].type;
  sort(a + 1, a + n + 1);
  for (long long i = 1; i <= n; i++) s += a[i].len;
  l = s - l;
  r = s - r;
  swap(l, r);
  for (long long i = 1; i < N; i++) dp[i] = -INF;
  for (long long i = 1; i <= n; i++) {
    for (long long j = N - 1; j >= 0; j--) {
      if (dp[j] == -INF) continue;
      dp[j + a[i].len] =
          max(dp[j + a[i].len],
              dp[j] + a[i].type * (l <= j + a[i].len && j + a[i].len <= r));
    }
  }
  long long ret = 0;
  for (long long i = 1; i < N; i++) {
    ret = max(ret, dp[i]);
  }
  cout << ret << "\n";
  return 0;
}
