#include #include using namespace atcoder; using namespace std; using ll=long long; using ld=long double; ld pie=3.141592653589793; ll mod=1000000007; ld inf=10000999999999900; pair> op(pair> a,pair> b){ if (a.first>b.first) { return a; }else if (a.first==b.first) { if (a.second.first>e(){ return {-inf,{-inf,-inf}}; } int main(){ ll n,m; cin >> n >> m; vectora(n),b(m); for (ll i = 0; i < n; i++) { cin >> a[i]; } for (ll i = 0; i < m; i++) { cin >> b[i]; } sort(b.begin(),b.end()); b.push_back(inf); vector>>p(n); for (ll i = 0; i < n; i++) { p[i]={(ld)((ld)a[i]/(ld)b[0]),{i,0}}; } segtree>,op,e>seg(p); vectorans(m); for (ll i = 0; i < m; i++) { pair>pp=seg.all_prod(); ans[i]=pp.second.first+1; pp.second.second++; pp.first=(ld)((ld)a[pp.second.first]/(ld)b[pp.second.second]); seg.set(pp.second.first,pp); } for (ll i = 0; i < m; i++) { cout << ans[i] << endl; } }