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.
 
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 2
3 2 3 1
0
 
Sample Output
17 41

电梯上升花6s,下降花4s,每次停留5s,按照列表中的顺序电梯开始升降与停留,求总耗时。

#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t)
{
int a[100],m,n=0;
m=t*5;
for (int i=0;i<t;i++)
{
cin>>a[i];
if(a[i]>n)
{
m+=(a[i]-n)*6;
n=a[i];
}
else
{
m+=(n-a[i])*4;
n=a[i];
}
}
cout<<m<<endl;
cin>>t;
}
return 0;
}

1008 Elevator的更多相关文章

  1. PAT 1008. Elevator (20)

    1008. Elevator (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The highest ...

  2. Problem : 1008 ( Elevator )

    好操蛋啊,电梯竟然能原地不动,你大爷的,这逻辑,太弱智了.... Problem : 1008 ( Elevator )     Judge Status : Accepted RunId : 103 ...

  3. PAT 1008 Elevator

    1008 Elevator (20 分)   The highest building in our city has only one elevator. A request list is mad ...

  4. PAT 甲级 1008 Elevator (20)(代码)

    1008 Elevator (20)(20 分) The highest building in our city has only one elevator. A request list is m ...

  5. PAT甲 1008. Elevator (20) 2016-09-09 23:00 22人阅读 评论(0) 收藏

    1008. Elevator (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The highest ...

  6. pat 1008 Elevator(20 分)

    1008 Elevator(20 分) The highest building in our city has only one elevator. A request list is made u ...

  7. 【PAT甲级】1008 Elevator (20分)

    1008 Elevator 题目: The highest building in our city has only one elevator. A request list is made up ...

  8. 1008 Elevator (20分)

    1008 Elevator (20分) 题目: The highest building in our city has only one elevator. A request list is ma ...

  9. PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642 题目描述: The highest building in our city has ...

  10. HDOJ 1008. Elevator 简单模拟水题

    Elevator Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Su ...

随机推荐

  1. ISO c++ 14 重点介绍[译]

    原文链接 http://marknelson.us/2014/09/11/highlights-of-iso-c14/ 下面是对你的日常开发有重大影响的C++14新变动,列出了一些示例代码,并讨论何时 ...

  2. CentOS 中 YUM 安装桌面环境(转)

    使用 yum groupinstall 指令很容易就能安装上图形界面的桌面系统. 1. yum 的 group 指令 yum 可以以程序组的模式来安装成套的软件包.支持的软件包可以通过, # yum ...

  3. loadrunner提高篇-插入检查点与关联函数

    插入检查点   靠LR自动生成的脚本是不够的,很难达到业务要求,因此需要对录制完的脚本进行完善,使其能达到业务模拟的要求 ,这样尽可能地使虚拟用户模拟时更接近用户的实际使用. 在进行压力测试时,经常会 ...

  4. 【2017-04-01】JS字符串的操作、时间日期的操作、函数、事件、动画基础

    一.字符串的操作 1.转大写: s.toLowerCase(); 2.转大写: s.toUpperCase(); 3.字符串的截取: s.substr(3,4);      -从索引3开始截取,截取4 ...

  5. webpack2.x基础属性讲解(一)

      webpack作为构建工具平时作为前端作为优化.模块编程.和分片打包的重要组成部分,大家可能并不陌生,如果没有时刻的去关注文档,那么大家可能不太清楚webpack已经默默然的升级到2.x了,对比1 ...

  6. 性能测试培训:Ajax接口级性能测试之jmeter版

    性能测试培训:Ajax接口级性能测试之jmeter版   poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.在poptest认为工具 ...

  7. 手机自动化测试:Appium源码之API(2)

    手机自动化测试:Appium源码之API(2)   TouchAction AppiumDriver的辅助类,主要针对手势操作,比如滑动.长按.拖动等.TouchAction的原理是讲一系列的动作放在 ...

  8. HNOI2017前被虐记及感悟

    本文所记录的时间以HNOI2017第一天考试时间为DAY1,前一天为DAY0,以此类推. 本文记载了博主从HNOI2017开始前一周进行全真模拟考试的被虐过程和结果.文章内可能包含博主的不良情绪,如果 ...

  9. C++迭代器 iterator【转】

    1. 迭代器(iterator)是一中检查容器内元素并遍历元素的数据类型.(1) 每种容器类型都定义了自己的迭代器类型,如vector:vector<int>::iterator iter ...

  10. Use “error_messages” in Rails 3.2? (raises “undefined method” error)

    I am getting the following error in my Rails 3.2 functional tests: ActionView::Template::Error: unde ...