#include <bits/stdc++.h>
struct node {
  int h, typ;
  bool operator<(node b) const {
    if (typ == b.typ) return h > b.h;
    return typ < b.typ;
  }
} a[10010];
int n, x, y, sum, L, R, ans, dp[10010];
int main() {
  scanf("%d%d%d", &n, &x, &y);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i].h), sum += a[i].h;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i].typ);
  L = sum - y, R = sum - x;
  std::sort(a + 1, a + n + 1);
  memset(dp, 128, sizeof(dp));
  dp[0] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = sum; j >= a[i].h; j--) {
      int res = dp[j - a[i].h];
      if (L <= j && R >= j) res += a[i].typ;
      dp[j] = std::max(dp[j], res);
    }
  for (int i = 0; i <= sum; i++) ans = std::max(ans, dp[i]);
  printf("%d\n", ans);
}
