#include #include #include #include #include #include #include #include int op(const int x, const int y) { return std::max(x, y); } constexpr int e() { return std::numeric_limits::min(); } // #910622 ベース int main() { constexpr int kMaxN = 5000, kMinA = -1000000000, kMaxA = 1000000000; int n, l, r; std::cin >> n >> l >> r; assert(1 <= n && n <= kMaxN && kMinA <= l && l <= r && r <= kMaxA); std::vector a(n); for (int i = 0; i < n; ++i) { std::cin >> a[i]; assert(kMinA <= a[i] && a[i] <= kMaxA); } std::ranges::sort(a); std::vector p_prime(n, n), q(n, -1), q_prime(n); for (int i = 0; i < n; ++i) { if (a[i] < 0) { for (int lb = -1; lb + 1 < p_prime[i];) { const int p = std::midpoint(lb, p_prime[i]); (a[i] * a[p] <= r ? p_prime[i] : lb) = p; } for (int ub = n; q[i] + 1 < ub;) { const int cand_q = std::midpoint(q[i], ub); (a[i] * a[cand_q] >= l ? q[i] : ub) = cand_q; } } else { for (int lb = -1; lb + 1 < p_prime[i];) { const int p = std::midpoint(lb, p_prime[i]); (a[i] * a[p] >= l ? p_prime[i] : lb) = p; } for (int ub = n; q[i] + 1 < ub;) { const int cand_q = std::midpoint(q[i], ub); (a[i] * a[cand_q] <= r ? q[i] : ub) = cand_q; } } if (q[i] < p_prime[i]) { p_prime[i] = n; q[i] = -1; } else { p_prime[i] = std::max(p_prime[i], i + 1); } q_prime[i] = std::min(q[i], i - 1); } int ans = 1; const atcoder::segtree seg(q_prime); for (int i = 0; i < n; ++i) { if (p_prime[i] <= q[i]) { const int f = 3 - p_prime[i] + seg.prod(p_prime[i], q[i] + 1); ans = std::max({ans, f, 2}); } } std::cout << ans << '\n'; return 0; }