// WA (嘘: 連続部分列のみを考えてよい (反例: 一部の答えが2のケース)) #include #include #include int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; long long l, r; std::cin >> n >> l >> r; std::vector a(n); for (auto &e : a) std::cin >> e; std::sort(a.begin(), a.end()); auto check = [&](const int k) -> bool { for (int i = 0; i + k <= n; ++i) { const long long x = a[i] * a[i + 1]; const long long y = a[i + k - 1] * a[i + k - 2]; const long long z = a[i] * a[i + k - 1]; const long long min_prod = std::min({ x, y, z }); const long long max_prod = std::max({ x, y, z }); if (l <= min_prod and max_prod <= r) { return true; } } return false; }; int ok = 1, ng = n + 1; while (ng - ok > 1) { int mid = (ok + ng) >> 1; (check(mid) ? ok : ng) = mid; } std::cout << ok << std::endl; }