CF1054A.Elevator or Stairs?
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Masha lives in a multi-storey building, where floors are numbered with positive integers. Two floors are called adjacent if their numbers differ by one. Masha decided to visit Egor. Masha lives on the floor x, Egor on the floor y (not on the same floor with Masha).
The house has a staircase and an elevator. If Masha uses the stairs, it takes t1 seconds for her to walk between adjacent floors (in each direction). The elevator passes between adjacent floors (in each way) in t2 seconds. The elevator moves with doors closed. The elevator spends t3 seconds to open or close the doors. We can assume that time is not spent on any action except moving between adjacent floors and waiting for the doors to open or close. If Masha uses the elevator, it immediately goes directly to the desired floor.
Coming out of the apartment on her floor, Masha noticed that the elevator is now on the floor z and has closed doors. Now she has to choose whether to use the stairs or use the elevator.
If the time that Masha needs to get to the Egor's floor by the stairs is strictly less than the time it will take her using the elevator, then she will use the stairs, otherwise she will choose the elevator.
Help Mary to understand whether to use the elevator or the stairs.
玛莎住在一栋多层建筑中,楼层编号为正整数。若两个楼层的编号相差为 1,则称这两个楼层为相邻楼层。玛莎决定去拜访叶戈尔。玛莎住在第 x 层,叶戈尔住在第 y 层(y=x)。
该楼内有一部楼梯和一部电梯。若玛莎走楼梯,则她在相邻楼层之间上下一层均需 t1 秒。电梯在相邻楼层之间运行(双向)需 t2 秒;电梯运行时门始终关闭。电梯每次开门或关门各需 t3 秒。除在相邻楼层间移动以及等待开关门之外,不消耗任何时间。若玛莎选择乘电梯,则电梯将立即直达目标楼层。
玛莎从自己家出门时发现:电梯当前位于第 z 层,且电梯门处于关闭状态。此时她需决定是走楼梯还是乘电梯。
若玛莎走楼梯到达叶戈尔所在楼层所需时间严格小于乘电梯所需时间,则她选择走楼梯;否则她选择乘电梯。
请帮助玛莎判断应选择电梯还是楼梯。
输入格式
The only line contains six integers x, y, z, t1, t2, t3 (1≤x,y,z,t1,t2,t3≤1000) — the floor Masha is at, the floor Masha wants to get to, the floor the elevator is located on, the time it takes Masha to pass between two floors by stairs, the time it takes the elevator to pass between two floors and the time it takes for the elevator to close or open the doors.
It is guaranteed that x=y.
唯一的一行包含六个整数 x、y、z、t1、t2、t3(1≤x,y,z,t1,t2,t3≤1000)——分别表示玛莎当前所在的楼层、玛莎想要到达的楼层、电梯当前所在的楼层、玛莎走楼梯经过两层楼所需的时间、电梯经过两层楼所需的时间,以及电梯开关门所需的时间。
保证 x=y。
输出格式
If the time it will take to use the elevator is not greater than the time it will take to use the stairs, print «YES» (without quotes), otherwise print «NO> (without quotes).
You can print each letter in any case (upper or lower).
如果使用电梯所需的时间不大于使用楼梯所需的时间,则输出 «YES»(不带引号),否则输出 «NO»(不带引号)。
你可以以任意大小写(大写或小写)输出每个字母。
输入输出样例
输入#1
5 1 4 4 2 1
输出#1
YES
输入#2
1 6 6 2 1 1
输出#2
NO
输入#3
4 1 7 4 1 2
输出#3
YES
说明/提示
In the first example:
If Masha goes by the stairs, the time she spends is 4⋅4=16, because she has to go 4 times between adjacent floors and each time she spends 4 seconds.
If she chooses the elevator, she will have to wait 2 seconds while the elevator leaves the 4-th floor and goes to the 5-th. After that the doors will be opening for another 1 second. Then Masha will enter the elevator, and she will have to wait for 1 second for the doors closing. Next, the elevator will spend 4⋅2=8 seconds going from the 5-th floor to the 1-st, because the elevator has to pass 4 times between adjacent floors and spends 2 seconds each time. And finally, it will take another 1 second before the doors are open and Masha can come out.
Thus, all the way by elevator will take 2+1+1+8+1=13 seconds, which is less than 16 seconds, so Masha has to choose the elevator.
In the second example, it is more profitable for Masha to use the stairs, because it will take 13 seconds to use the elevator, that is more than the 10 seconds it will takes to go by foot.
In the third example, the time it takes to use the elevator is equal to the time it takes to walk up by the stairs, and is equal to 12 seconds. That means Masha will take the elevator.
在第一个例子中:
如果玛莎走楼梯,她花费的时间为 4⋅4=16 秒,因为她需要在相邻楼层之间上下共 4 次,每次耗时 4 秒。
如果她选择乘坐电梯,则首先需等待 2 秒,让电梯从第 4 层出发并抵达第 5 层;随后电梯门将再花 1 秒开启;接着玛莎进入电梯,并再等待 1 秒待电梯门关闭;之后电梯将花费 4⋅2=8 秒从第 5 层下行至第 1 层(因需经过 4 段相邻楼层,每段耗时 2 秒);最后,电梯门再次开启、玛莎走出电梯还需 1 秒。
因此,全程乘电梯共耗时 2+1+1+8+1=13 秒,少于 16 秒,故玛莎应选择电梯。
在第二个例子中,对玛莎而言走楼梯更为划算,因为乘电梯需耗时 13 秒,多于步行所需的 10 秒。
在第三个例子中,乘电梯所需时间与走楼梯所需时间相等,均为 12 秒。这意味着玛莎将选择乘坐电梯。
输入解题思路,AI测评打分。不知道怎么写?