#C11989. Battery Assignment for Robots
Battery Assignment for Robots
Battery Assignment for Robots
In this problem, you are given one or more test cases. In each test case, there is a set of robots and a set of batteries. Every robot requires a minimum charge for operation. Robots will choose the first available battery (in the order provided) which is not yet used and whose available charge is at least as high as the robot's requirement.
Formally, for each test case, you are given two integers \( n \) and \( m \) where \( n \) is the number of robots and \( m \) is the number of batteries. You are also given an array \( R \) of \( n \) integers representing the required charge for each robot, and an array \( B \) of \( m \) integers representing the available charge of each battery. For each robot in order, assign a battery (using 1-based indexing) if there exists a battery with a charge \( \geq \) the robot's requirement that has not been used yet. If no such battery exists, assign \( -1 \) for that robot.
Output the assigned battery indices for each robot in each test case. Each test case output should be printed on a separate line with indices separated by a space.
inputFormat
The first line of the input contains an integer \( T \) representing the number of test cases. For each test case:
- The first line contains two integers \( n \) and \( m \) separated by a space, where \( n \) is the number of robots and \( m \) is the number of batteries.
- The second line contains \( n \) integers representing the required charge for each robot.
- The third line contains \( m \) integers representing the available charge for each battery.
All input is read from stdin.
outputFormat
For each test case, output a single line containing \( n \) integers. Each integer represents the 1-based index of the battery assigned to each robot or \( -1 \) if no suitable battery exists. The outputs for different test cases should be separated by a newline, and all output must be written to stdout.
## sample1
3 4
5 8 3
7 3 6 10
1 4 2
</p>