#![allow(non_snake_case, unused_imports, unused_must_use)] use std::io::{self, prelude::*}; use std::str; fn main() { let (stdin, stdout) = (io::stdin(), io::stdout()); let mut scan = Scanner::new(stdin.lock()); let mut out = io::BufWriter::new(stdout.lock()); macro_rules! input { ($T: ty) => { scan.token::<$T>() }; ($T: ty, $N: expr) => { (0..$N).map(|_| scan.token::<$T>()).collect::>() }; } let N = input!(usize); let M = input!(usize); let A = input!(f64, N); let B = input!(f64, M); let mut low = 0 as f64; let mut high = (1 << 30) as f64; while high - low > 0.001 as f64 { let m = (low + high) / 2.0; let mut cnt = 0; for &a in A.iter() { if a / B[0] < m { continue; } let mut ok = 0; let mut ng = M; while ng - ok > 1 { let m2 = (ok + ng) / 2; if a / B[m2] < m { ng = m2; } else { ok = m2; } } cnt += ok + 1; } if cnt < M { high = m; } else { low = m; } } let mut ans = vec![]; for i in 0..N { for j in 0..M { if A[i] / B[j] < low { break; } ans.push((A[i] / B[j], i)); } } ans.sort_by_key(|&(_, i)| i); ans.sort_by_key(|&(v, _)| -(v as isize)); for i in 0..M { writeln!(out, "{}", ans[i].1 + 1); } } struct Scanner { reader: R, buf_str: Vec, buf_iter: str::SplitWhitespace<'static>, } impl Scanner { fn new(reader: R) -> Self { Self { reader, buf_str: vec![], buf_iter: "".split_whitespace(), } } fn token(&mut self) -> T { loop { if let Some(token) = self.buf_iter.next() { return token.parse().ok().expect("Failed parse"); } self.buf_str.clear(); self.reader .read_until(b'\n', &mut self.buf_str) .expect("Failed read"); self.buf_iter = unsafe { let slice = str::from_utf8_unchecked(&self.buf_str); std::mem::transmute(slice.split_whitespace()) } } } }