标题:电梯问题!自己做老是错!!
只看楼主
singleheaven
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2008-8-3
 问题点数:0 回复次数:2 
电梯问题!自己做老是错!!
The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one floor, and 4 seconds to move down one floor. The elevator will stay for 5 seconds at each stop.

For a given request list, you are 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 have to return to the ground floor when the requests are fulfilled.


nput
There are multiple test cases. Each case contains a positive integer N, followed by N positive numbers. All the numbers in the input are less than 100. A test case with N = 0 denotes the end of input. This test case is not to be processed.

 

Output
Print the total time on a single line for each test case.

 

Sample Input
1 2
3 2 3 1
0
 

Sample Output
17
41
搜索更多相关主题的帖子: 电梯 
2008-08-05 09:24
w362034710
Rank: 1
等 级:新手上路
帖 子:169
专家分:0
注 册:2006-12-2
得分:0 
不太明白3 2 3 1结果 是41
2008-08-05 16:07
singleheaven
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2008-8-3
得分:0 
[bo][un]w362034710[/un] 在 2008-8-5 16:07 的发言:[/bo]

不太明白3 2 3 1结果 是41

三十输入3个数字,然后是由0开始到第2楼,
在一楼停5秒,然后到2楼,
花费时间17秒!
因为每上一楼要六秒!
然后到三楼,上一楼六秒,外加在2楼停5秒!
28秒了!
然后下到一楼!
下一楼时间是4秒!
所以到1楼要13秒!
总共 41秒!!
2008-08-05 18:30



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-226843-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.762192 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved