use std::io::Read; fn main() { let mut all_data = String::new(); std::io::stdin().read_to_string(&mut all_data).ok(); let mut all_data = all_data.trim().split('\n').map(|s| s.trim()); let nmk: Vec = all_data.next().unwrap().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n: usize = nmk[0]; let m: usize = nmk[1]; let k: usize = nmk[2]; let opb: Vec<&str> = all_data.next().unwrap().split_whitespace().collect(); let mut b: Vec = opb.iter().skip(1).map(|s| s.parse().unwrap()).collect(); b.sort(); let op: &str = opb[0]; let a: Vec = all_data.take(n as usize).map(|s| s.parse().unwrap()).collect(); let mut result: usize = 0; for i in a.iter() { let mut lower = 0; let mut upper = m - 1; let mut middle = (lower + upper) / 2; while upper - lower > 0 { let target = match op { "+" => i + b[middle], "*" => i * b[middle], _ => 0 }; if target < k { lower = middle + 1; } else { upper = middle; } middle = (lower + upper) / 2; println!("{} {} {} {} {:?}", lower, upper, middle, target, b); } let target = match op { "+" => i + b[middle], "*" => i * b[middle], _ => 0 }; result += m - middle + if target >= k { 1 } else { 0 } - 1; } println!("{}", result); }