You are given two variants of route, one with length equal to sqrt(2) * N and maximal velocity V_1, and another with length equal to 2 \cdot N and maximal velocity V_2. You have to find which route will use less time.

QUICK EXPLANATION:

S = v * t, so just calculate time of both routes.
The complexity is O(1) for one testcase, O(T) in total.

EXPLANATION:

Time of the first route is T_1 = \frac{sqrt(2) * N}{ V_1}. Time of the second T_2 = \frac{2 * N}{V_2}.
So, we can compare this fractional numbers, or, alternatively, make some transitions and get that:

T_1 ? T_2

V_2 * sqrt(2) ? V_1 * 2

V_2 ? V_1 * sqrt(2)

So, the first route is faster if V_2 < V_1 * sqrt(2). Why the times couldn’t be equal? Imagine that V_2 = V_1 * sqrt(2). V_2 is integer, while V_1 * sqrt(2) is irrational. Obviously, they can’t be equal.

AUTHOR’S AND TESTER’S SOLUTIONS:

Author’s solution can be found here.
Tester’s solution can be found here.

The sample outputs above are all ‘Elevator’.
For the case of stairs, the distance is sqrt(2) * N;
velocity is v1 (i.e. not changed).
The time required for moving is derived from
dividing the distance by the velocity.
The above result comes from the following code in Python.

t=int(input())
for x in range(t):
n,v1,v2=map(int, input().split())
if n2**0.5/v1 > n/v2:
print(‘Elevator’)
elif n2**0.5/v1 < n/v2:
print(‘Stairs’)