Escalator
InterviewTime limit1sMemory limit1024 MB
Given escalator length, standing and walking speeds, two entry rates, and two queue lengths, decide which line reaches the top first.
- Level
Medium4 of 10
- Topics
- Math, Simulation, Implementation, Greedy
- Solved
- No attempts yet
Problem
Paulina Osqulda (Osqulda is a student slang term for engineering students at the Royal Institute of Technology in Stockholm, see https://sv.wikipedia.org/wiki/Osquar_och_Osqulda.) studies at KTH in Stockholm and takes the subway to school every morning. When she reaches her subway station, she has to ride up an escalator to get out.
Two different lines often form at the escalator. On the right side of the escalator, people who want to stand still line up, while on the left side people line up if they prefer to walk in the escalator (to get up faster).
Paulina has noticed that a very long line usually forms on the left side of the escalator, because everyone is so stressed about getting to work and wants to be able to walk quickly up the escalator. Lately she has been wondering whether it might even be faster to choose the right line instead, since that line is often shorter.
The escalator is a total of steps long. If you stand in the escalator, you travel steps per second upward. If you walk in the escalator instead, you travel steps per second upward.
In total, people per second can step onto the escalator from the left line, while people per second can step onto the escalator from the right line. This means that at the start of the process, one person steps onto the escalator. Before a new person steps onto the escalator, that person must wait (respectively ) seconds to be able to step onto the escalator.
The left line is currently people long, and the right line is people long.
Help Paulina decide which line to stand in so that she reaches the top of the escalator as quickly as possible.
Input
The first line of the input consists of the integers described in the problem. It holds that , .
The next line contains the real numbers described in the problem. It holds that .
The last line contains the integers described in the problem. It holds that .
Output
Print latmask if the fastest option is to choose the right line and stand in the escalator, or friskus if the fastest option is to choose the left line and walk in the escalator.
It is guaranteed that the time for Paulina to ride up the escalator differs by at least 1 second between the two lines, so you never need to worry about the case where both options are equally fast.