use std::collections::BinaryHeap; use std::cmp::Reverse; fn main() { let mut input = String::new(); std::io::stdin().read_line(&mut input).unwrap(); let mut input_iter = input.split_whitespace(); let _: usize = input_iter.next().unwrap().parse().unwrap(); let _: usize = input_iter.next().unwrap().parse().unwrap(); input.clear(); std::io::stdin().read_line(&mut input).unwrap(); let a: Vec = input.split_whitespace().map(|x| x.parse().unwrap()).collect(); input.clear(); std::io::stdin().read_line(&mut input).unwrap(); let b: Vec = input.split_whitespace().map(|x| x.parse().unwrap()).collect(); let mut ai: Vec<(i64, usize)> = a.iter().enumerate().map(|(i, &x)| (x, i)).collect(); ai.sort_by_key(|x| Reverse(x.0)); let mut heap: BinaryHeap<(i64, usize)> = BinaryHeap::new(); // u64型を使用 let (a_max, i_max) = ai[0]; for &b_j in b.iter() { let p = (a_max as f64 / b_j as f64 * 1e6) as i64; heap.push((-p, i_max)); } for &(a_i, i) in ai.iter().skip(1) { for &b_j in b.iter() { let p = (a_i as f64 / b_j as f64 * 1e6) as i64; // 小数点以下を考慮 heap.push((-p, i)); // u64型を使用 if let Some((p2, i2)) = heap.pop() { if p != -p2 || i != i2 { break; } } } } let mut ans: Vec = Vec::new(); while let Some((_, i)) = heap.pop() { ans.push(i+1); } ans.reverse(); for &x in ans.iter() { println!("{}", x); } }