杭电1008 Elevator
来源:互联网 发布:网络推广怎么收费 编辑:程序博客网 时间:2024/05/16 12:52
Elevator
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 40520 Accepted Submission(s): 22177
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<iostream>using namespace std;int main(){ int t0,t,n,sum,k; while(cin>>n&&n!=0) { t0=0; sum=0; k=0; while(n--) { cin>>t;; if(t>t0) sum+=(t-t0)*6; else sum+=(t0-t)*4; t0=t; k++; } sum+=k*5; cout<<sum<<endl; } return 0;}
0 0
- 杭电1008 Elevator
- 杭电1008 Elevator
- 杭电1008 Elevator
- Elevator 杭电1008
- 杭电 1008 Elevator
- 杭电1008 Elevator
- 杭电 1008 Elevator
- 杭电 1008 Elevator
- 杭电1008-Elevator
- 杭电 1008 Elevator
- 杭电1008 Elevator
- 杭电ACM 1008Elevator
- 杭电ACM-1008 Elevator
- 杭电ACM-1008-Elevator
- 杭电acm 1008 Elevator
- 杭电 ACM 1008:Elevator
- 杭电ACM 1008Elevator
- 杭电 HDOJ 1008 Elevator
- Android的服务器搭建
- 递推—杭电2044 一只小蜜蜂...
- Python画图
- SGU 467 Chessmaster 几何
- Extjs4 Excel导入并在grid显示数据
- 杭电1008 Elevator
- 安卓加速传感器开发
- 2014.1.13 杭电习题 二维字符串中出现数量最多的字符串
- 常用网址资源
- Unable to resolve target 'android-8'
- Extjs4 使用lodop打印控件心得
- phpstorm 快捷键
- 2014.1.13 杭电习题 绝对值排序
- libevent源码分析--event_init()函数