HDU1008:Elevator
来源:互联网 发布:天敏网络机顶盒d6双核 编辑:程序博客网 时间:2024/06/07 23:03
Elevator
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 42155 Accepted Submission(s): 23093
Problem Description
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.
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.
Input
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 23 2 3 10
Sample Output
1741
#include<stdio.h>int main(){ int n,i,t,a,b; while(scanf("%d",&n)&&n!=0) { t=0,a=0; for(i=0;i<n;i++) { scanf("%d",&b); if(a<=b) t+=5+6*(b-a); else t+=5+4*(a-b); a=b; } printf("%d\n",t); } return 0;}
0 0
- HDU1008 Elevator
- HDU1008 Elevator
- hdu1008 Elevator
- HDU1008:Elevator
- hdu1008 Elevator
- HDU1008-Elevator
- hdu1008 Elevator
- HDU1008 Elevator
- HDU1008 Elevator
- HDU1008 Elevator
- HDU1008-Elevator
- hdu1008 Elevator
- HDU1008(elevator)
- hdu1008——Elevator
- hdu1008 Elevator(模拟)
- HDU1008—Elevator
- HDU1008 ZOJ2108 Elevator
- HDU1008——Elevator
- Codeforces D. Giving Awards 412 题解
- javaScript排序
- MySQL 日志分类详解(二)
- java编程实现单链表的建立
- Web服务规范SOAP之处理附件
- HDU1008:Elevator
- ContentProvider原理及实例
- 对虚拟视的研究
- 数据分析与挖掘书单推介
- 第19条:接口只用于定义类型
- 精通安卓性能优化-第三章(二)
- C# 开源库大全
- 维基 1219 骑士游历
- 修正出货单确认时计算客户信用度(s_ccc.4gl)_订单未转出货金额BUG