计算多组数据中电梯的不同路径所用的时间
来源:互联网 发布:mac os下载 编辑:程序博客网 时间:2024/06/06 18:18
Problem DescriptionThe 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.InputThere 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.OutputPrint the total time on a single line for each test case. Sample Input1 23 2 3 10Sample Output1741#include <iostream>using namespace std;int main(){ int a[100],n,i; while(cin>>n&&n!=0) { int s=0; for(i=0;i<n;i++) cin>>a[i]; s+=a[0]*6+5; for(i=1;i<n;i++) { if(a[i]>a[i-1]) s+=6*(a[i]-a[i-1])+5; else s+=4*(a[i-1]-a[i])+5; } cout<<s<<endl; } return 0;}
<img src="http://img.blog.csdn.net/20150127134140001?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYTcxNjEyMQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
0 0
- 计算多组数据中电梯的不同路径所用的时间
- 在LotusScript程序中如何计算程序所用的时间
- 计算加载页面所用的时间
- 例6 用LabVIEW计算生成等于某个给定值的随机数据所用时间
- 【例6】计算生成等于某个给定值的随机数据所用时间
- Activity所用的时间
- 【C++学习笔记】计算程序运行所用的时间
- 电梯时间计算
- (10)SVG中所用到的形状简介------定义路径
- 执行语句所用的时间
- 在sql*plus中显示语句执行所用的时间
- eclipse中获得程序执行的所用时间
- C语言下产生大量的随机数和计算程序运行所用的时间
- hdu1008简单电梯时间计算
- 开发日志:计算Java内一段代码运行所用的时间
- 计算代码段所用时间
- 计算所用时间和频率
- HDOJ_1008电梯上的时间(Elevator)
- 对函数指针,指针函数和指针的指针理解。
- 实现imageview直接利用url实现加载图片
- 如何构建超强伸缩性的游戏服务器而集容错、负载均衡和无限伸缩性于一身(erlang)
- poj 1265 皮克定理+多边形面积+边上点的数量的求取
- android 修改源码framework后如何编译
- 计算多组数据中电梯的不同路径所用的时间
- window.showModalDialog以及window.open用法简介
- Mysql存储引擎简介
- Web项目目录规范
- CODEVS 1076 排序(快排)
- mysq不能从远程连接解决办法
- Triangle
- 理解ThreadLocal
- zoj 1456