pub mod scanner { pub struct Scanner { buf: Vec, } impl Scanner { pub fn new() -> Self { Self { buf: vec![] } } pub fn new_from(source: &str) -> Self { let source = String::from(source); let buf = Self::split(source); Self { buf } } pub fn next(&mut self) -> T { loop { if let Some(x) = self.buf.pop() { return x.parse().ok().expect(""); } let mut source = String::new(); std::io::stdin().read_line(&mut source).expect(""); self.buf = Self::split(source); } } fn split(source: String) -> Vec { source .split_whitespace() .rev() .map(String::from) .collect::>() } } } use crate::scanner::Scanner; use std::io::Write; fn main() { let mut scanner = Scanner::new(); let out = std::io::stdout(); let mut out = std::io::BufWriter::new(out.lock()); let t: usize = 1; for _ in 0..t { solve(&mut scanner, &mut out); } } fn solve(scanner: &mut Scanner, out: &mut std::io::BufWriter) { let n = scanner.next::(); let l = scanner.next::(); let r = scanner.next::(); let mut pos = vec![]; let mut neg = vec![]; let mut zero = 0usize; for _ in 0..n { let a = scanner.next::(); if a > 0 { pos.push(a); } else if a < 0 { neg.push(a); } else { zero += 1; } } pos.sort(); neg.sort(); if 0 <= l { let mut ans = 0; for a in [&pos, &neg] { let mut li: usize = !0; let mut ri: usize = 0; for i in 0..a.len() - 1 { let b = a[i] * a[i + 1]; if l <= b && b <= r { li = li.min(i); ri = ri.max(i + 1); } } let mut res = if li != !0 { ri - li + 1 } else { a.len().min(1) }; if l == 0 { res += zero; } ans = ans.max(res); } writeln!(out, "{}", ans).unwrap(); return; } if r <= 0 { let mut ans = 0; ans = ans.max(pos.len().min(1)); ans = ans.max(neg.len().min(1)); 'outer: for i in 0..pos.len() { for j in 0..neg.len() { let b = pos[i] * neg[j]; if l <= b && b <= r { ans = 2; break 'outer; } } } if r == 0 { ans += zero; } writeln!(out, "{}", ans).unwrap(); return; } let mut ans = 0; ans = ans.max(pos.len().min(1) + zero); ans = ans.max(neg.len().min(1) + zero); for i in 1..pos.len() { let b = pos[i - 1] * pos[i]; if l <= b && b <= r { ans = ans.max(i + 1 + zero); } } for j in 0..neg.len() - 1 { let b = neg[j] * neg[j + 1]; if l <= b && b <= r { ans = ans.max(neg.len() - j + zero); } } for i in 0..pos.len() { for j in 0..neg.len() { let mut ok = true; if i > 0 { let b = pos[i - 1] * pos[i]; ok &= l <= b && b <= r; } if j < neg.len() - 1 { let b = neg[j] * neg[j + 1]; ok &= l <= b && b <= r; } let b = pos[i] * neg[j]; ok &= l <= b && b <= r; if ok { ans = ans.max(i + 1 + neg.len() - j + zero); } } } writeln!(out, "{}", ans).unwrap(); }