#include <bits/stdc++.h>
using namespace std;
const int N = 10050;
struct node {
  int p, w;
} a[N];
bool cmp(node x, node y) {
  if (x.p == y.p) return x.w > y.w;
  return x.p < y.p;
}
int n, l, r, sum;
int dp[N], ans;
int main() {
  scanf("%d%d%d", &n, &l, &r);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i].w);
    sum += a[i].w;
  }
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i].p);
  sort(a + 1, a + n + 1, cmp);
  int L = sum - r;
  int R = sum - l;
  l = L;
  r = R;
  memset(dp, 128, sizeof dp);
  dp[0] = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = sum; j >= a[i].w; --j) {
      if (l <= j && r >= j)
        dp[j] = max(dp[j], dp[j - a[i].w] + a[i].p);
      else
        dp[j] = max(dp[j], dp[j - a[i].w]);
    }
  for (int i = 1; i <= sum; ++i)
    if (dp[i] > ans) ans = dp[i];
  printf("%d\n", ans);
}
