The Perfect Road
Practice
2.1 (9 votes)
Ad Hoc
Basic programming
Easy
Problem
58% Success 2604 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Given that, there are N paths numbered from 1 to N, where each path connects the starting point S to the destination point X. The maximum speed limit is speed[i] for the \(i^{th}\) path which can be used to reach the destination. Find the path to reach the destination as early as possible. If there are multiple paths from which you can choose, print Many Roads. Also, it is guaranteed that X will always be greater than S.

Input format:
First line will contain the number of test cases T.
Each test case will be as follows:
First line consists of S, X and N, which denotes the starting point, destination point and number of paths respectively.
Next line will contain N numbers that denote maximum speed limit of the paths.

Output Format:
For each test case, output a single integer denoting the path chosen to reach the destination as early as possible. If there are multiple paths from which you can choose, you have to output "Many Roads" without quotes.

Input Constraints:
\(1 \le T \le 100\)
\(1 \le N \le 10^5\)
\( 0 \le \)S, \(X \le 10^9\)
\(1 \le speed[i] \le 10^9\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
31 votes
Tags:
Ad-HocBrute-force searchEasyImplementation
Points:20
29 votes
Tags:
ApprovedBasic ProgrammingEasy
Points:20
11 votes
Tags:
Easy