AmazonOA #379
Get Trucks for Items
估计中等可在线判题
Each package independently chooses a truck whose capacity is strictly greater than its weight: first minimize the capacity, then choose the smallest original index among trucks with that capacity. Indices start at 0; output −1 if no truck is available. Loading does not consume truck capacity.
输入格式
The first line contains n m, the second line contains n capacities, and the third line contains m weights. Original bounds: 1≤n,m≤100000; capacities and weights are all 1..10^9.
输出格式
Output m truck indices or −1, in package order.
样例 1
输入:
4 3
5 3 5 8
3 5 8
输出:
0 3 -1
样例 2
输入:
2 3
4 2
1 2 4
输出:
1 0 -1
样例 3
输入:
3 2
2 2 3
1 2
输出:
0 2
样例说明
The outputs of the three public examples are, in order: 0 3 -1; 1 0 -1; 0 2. Verified by independent enumeration or direct simulation.