#C8056. Optimal Relay Race Ordering
Optimal Relay Race Ordering
Optimal Relay Race Ordering
You are given a list of robots each with a speed rating and a required number of laps. The time taken by the i-th robot is computed by the formula: $$T_i = \frac{L_i}{S_i}$$, where \(L_i\) is the number of laps and \(S_i\) is the speed of the robot.
Your task is to determine the optimal order (using 1-indexing) in which the robots should run so that the total relay race time is minimized. In case two robots have the same total time, the robot with the smaller index should run first.
inputFormat
The input is provided via standard input (stdin) and consists of three lines:
- The first line contains a single integer (n), the number of robots.
- The second line contains (n) space-separated integers representing the speeds of the robots.
- The third line contains (n) space-separated integers representing the number of laps each robot must complete.
outputFormat
Print a single line to standard output (stdout) containing (n) space-separated integers. These integers represent the optimal order (1-indexed) of the robots that minimizes the total relay race time.## sample
3
2 1 3
5 4 3
3 1 2
</p>