Exercises Mail.ru Cup 2018 Round 1-a. Elevator or stairs?

Source: Internet
Author: User

Topic

A. Elevator or stairs?

Description

Masha to go from the X-storey to the Y-floor to find Egor, you can choose to climb stairs or take a helicopter elevator. It is known that climbing stairs each layer needs time T1; The helicopter elevator each floor needs time T2, the helicopter elevator opens or closes once needs the time T3, the current helicopter elevator in the z floor, the helicopter elevator door is in the closed state. If the total time to climb stairs is strictly less than the helicopter elevator, then choose to climb the stairs and output yes, otherwise choose to take the helicopter elevator and output No.

Data range: 1<=x,y,z,t1,t2,t3<=1000

Ideas

Total length of Stair climb: t1*abs (x-y)

Total duration of helicopter lift: t2* (ABS (X-Z) +abs (x-y)) +t3*3

Note: The helicopter elevator door needs to switch three times altogether

"My Implementation"

1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <algorithm>6 7 using namespacestd;8 9InlineintMy_abs (intx)Ten { One     returnX <0? -x:x; A } -  - intMain () the { -     intx, y, z, t1, t2, T3; -     intA, B; -scanf"%d%d%d%d%d%d", &x, &y, &z, &t1, &t2, &T3); +A = T1 * My_abs (yx); -b = T2 * (My_abs (x-z) + my_abs (x-y)) +3*T3; +     //cout << a << ' << b <<endl; A     if(b <=a) atprintf"YES"); -     Else -printf"NO"); -     return 0; -}
View Code

"Evaluation Results"

Exercises Mail.ru Cup 2018 Round 1-a. Elevator or stairs?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.