fn main() { let stdin = std::io::read_to_string(std::io::stdin().lock()).unwrap(); let mut stdin = stdin.split_ascii_whitespace(); let n: usize = stdin.next().unwrap().parse().unwrap(); let m: usize = stdin.next().unwrap().parse().unwrap(); let k: u32 = stdin.next().unwrap().parse().unwrap(); let op: char = stdin.next().unwrap().parse().unwrap(); let b: Vec = (0..m) .map(|_| stdin.next().unwrap().parse().unwrap()) .collect(); let a: Vec = (0..n) .map(|_| stdin.next().unwrap().parse().unwrap()) .collect(); use std::io::Write; std::io::stdout() .lock() .write_all(output(solve(k, op, a, b)).as_bytes()) .unwrap(); } fn solve(k: u32, op: char, a: Vec, mut b: Vec) -> u64 { b.sort_unstable(); let b = b; b.len() as u64 * a.len() as u64 - match op { '+' => a .into_iter() .map(|a| mylib::lower_bound(&b, &(k.saturating_sub(a))) as u64) .sum::(), '*' => a .into_iter() .map(|a| mylib::lower_bound(&b, &((k + a - 1) / a)) as u64) .sum::(), _ => unreachable!(), } } fn output(ans: u64) -> String { ans.to_string() + "\n" } mod mylib { pub fn lower_bound(v: &[T], border: &T) -> usize { if v.is_empty() || v[0] >= *border { return 0; } let mut l: usize = 0; let mut r: usize = v.len(); while l + 1 < r { let c = (l + r) / 2; if v[c] < *border { l = c; } else { r = c; } } r } }