#include #include #define rep(i,n) for(int i=0;i vi; typedef vector vl; typedef vector> vvi; typedef vector> vvl; typedef pair P; typedef long double ld; struct Rational{ ll p, q; Rational(ll p, ll q) : p(p), q(q) {} bool operator<(const Rational& right) const{ return p * right.q < q * right.p; } }; int main(){ int n, m; cin >> n >> m; vl a(n), b(m); rep(i, n) cin >> a[i]; rep(i, m) cin >> b[i]; priority_queue> pq; vi cnt(n); rep(i, n){ Rational rational(a[i], b[0]); pq.emplace(rational, -i); } rep(i, m){ auto [rational_tmp, j] = pq.top(); pq.pop(); j *= -1; cout << j + 1 << "\n"; cnt[j]++; Rational rational(a[j], b[cnt[j]]); pq.emplace(rational, -j); } return 0; }