#include using namespace std; using ll = long long; using P = pair; // {score, party} int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, M; cin >> N >> M; vector A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; } vector B(M); for (int j = 0; j < M; ++j) { cin >> B[j]; } priority_queue

pq; vector index(N, 0); for (int i = 0; i < N; ++i) { double initial_score = static_cast(B[0]) / A[i]; pq.push({initial_score, i}); } vector result; for (int k = 0; k < M; ++k) { auto [score, party] = pq.top(); pq.pop(); result.push_back(party + 1); if (++index[party] < M) { double next_score = static_cast(B[index[party]]) / A[party]; pq.push({next_score, party}); } } for (int k = 0; k < M; ++k) { cout << result[k] << "\n"; } return 0; }