Roy and Trains
Practice
3.8 (18 votes)
Approved
Easy
Implementation
Math
Open
Problem
51% Success 17542 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Roy and Alfi reside in two different cities, Roy in city A and Alfi in city B. Roy wishes to meet her in city B.

There are two trains available from city A to city B. Roy is on his way to station A (Railway station of city A). It will take \(T_0\) time (in minutes) for Roy to reach station A. The two trains departs in \(T_1\) and \(T_2\) minutes respectively. Average velocities (in km/hr) of trains are \(V_1\) and \(V_2\) respectively. We know the distance D (in km) between city A and city B. Roy wants to know the minimum time (in minutes) to reach city B, if he chooses train optimally.

If its not possible to reach city B, print "-1" instead (without quotes).

Note: If the minimum time is not integral, round the value to the least integer greater than minimum time.

Input:

First line will contain integer T, number of test cases.

Second line will contain integers ** \(T_0, T_1, T_2, V_1, V_2, D\) ** (their meanings are mentioned in problem statement)

Output:

Print the integral result, minimum time (in minutes) to reach city B in a new line.

Constraints:

\(1 \le T \le 10000\)

\(1 \le T_0,T_1,T_1 \le 1000\)

\( 1 \le V_1,V_2 \le 500\)

\(1 \le D \le 5000\)

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
21 votes
Tags:
Basic ProgrammingBasics of ImplementationEasyGame TheoryImplementationLogic-BasedLogical Reasoning
Points:20
41 votes
Tags:
Ad-HocEasyImplementation
Points:20
27 votes
Tags:
ImplementationBasic ProgrammingBasic Math