#K71487. Maintenance Schedule Simulation
Maintenance Schedule Simulation
Maintenance Schedule Simulation
In this problem, you are tasked with simulating a vehicle maintenance process. There are ( n ) vehicles arriving in a given order and a required priority order for processing them. The vehicles are processed as follows: at each time unit, check the vehicle at the front of the arrival queue. If it matches the front of the priority order, it is removed from both lists; otherwise, it is moved to the back of the queue. The process repeats until all vehicles have been maintained. Your goal is to compute the total time required to complete the maintenance of all vehicles. This problem involves queue simulation and requires careful management of the orders to achieve the correct result.
inputFormat
The input begins with an integer ( T ) representing the number of test cases. For each test case, the first line contains an integer ( n ) (the number of vehicles). The second line contains ( n ) space-separated integers that represent the arrival order. The third line contains ( n ) space-separated integers that represent the ideal priority order for maintenance.
outputFormat
For each test case, output a single line with one integer: the total time required to complete maintenance for all vehicles.## sample
1
4
4 1 2 3
1 2 3 4
5
</p>