Elevator
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 52791 Accepted Submission (s): 29174
Problem DescriptionThe Highest building in We City have only one elevator. A request list is made to with N positive numbers. The numbers denote at which floors the elevator would stop, in specified order. It costs 6 seconds to move the elevator-one floor, and 4 seconds to move-down-one floor. The elevator would stay for 5 seconds on each stop.
For a given request list, you is to compute the total time spent to fulfill the requests on the list. The elevator is on the 0th floor at the beginning and does not having to return to the ground floor when the requests was Fu Lfilled.
Inputthere is multiple test cases. Each case contains a positive an integer n, followed by N positive numbers. All the numbers in the input is less than 100. A test Case with N = 0 denotes the end of input. This test is a not-to-be processed.
Outputprint the total time, on a, on a, a, and each test case.
Sample INPUT1 23 2 3 10
Sample Output1741
Authorzheng, Jianqiang
SourceZJCPC2004
recommendjgshining | We have carefully selected several similar problems for you:1071 1170 1006 1007 1032 Math water problem, especially simpleTest Instructions: There is one tallest building in our city, but there is only one elevator in this building. Now there is a request list consisting of n positive integers, representing the floors to which a group of people will arrive. And this elevator takes 6 seconds to rise a layer, 4 seconds to drop a layer, each floor of the residence time is 5 seconds. For the given list of requests, how long does it take to get that group of people to reach their respective floors? Find out the time. Let's say that the elevator starts at the 0 floor and does not need to go back to the 0 floor when the person is delivered. attached code:
1#include <iostream>2#include <cstdio>3 using namespacestd;4 intMain ()5 {6 intn,m,i,j;7 while(~SCANF ("%d", &n) &&N)8 {9 intsum=0, t=0;Ten while(n--) One { Ascanf"%d",&m); - if(m>t)//upstairs -sum=sum+ (M-T) *6; the Else //downstairs -sum=sum+ (T-M) *4; -sum+=5;//takes 5 seconds per stay -t=m; + } -printf"%d\n", sum); + } A}
HDU 1008 Elevator