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 Specification:

Each input file contains one test case. Each case contains a positive integer N, followed by N positive numbers. All the numbers in the input are less than 100.

Output Specification:

For each test case, print the total time on a single line.

Sample Input:

3 2 3 1

Sample Output:

41
 考了英语。看清题目没有难度
#include <iostream>

using namespace std;

int main(){
int N;cin>>N;
int bef=-,now,sum=;
while(N--){
cin>>now;
if(bef==-) sum+=(now*+);
else if(now>bef) sum+=((now-bef)*+);
else sum+=((bef-now)*+);
bef=now;
}
cout<<sum;
return ;
}

PAT Advanced 1008 Elevator (20 分)的更多相关文章

  1. PAT Advanced 1008 Elevator (20) [数学问题-简单数学]

    题目 The highest building in our city has only one elevator. A request list is made up with N positive ...

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

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

  3. 1008 Elevator (20分)

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

  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 题目: The highest building in our city has only one elevator. A request list is made up ...

  7. PAT (Advanced Level) Practice 1008 Elevator (20 分) (模拟)

    The highest building in our city has only one elevator. A request list is made up with N positive nu ...

  8. PAT 甲级 1008 Elevator (20)(20 分)模拟水题

    题目翻译: 1008.电梯 在我们的城市里,最高的建筑物里只有一部电梯.有一份由N个正数组成的请求列表.这些数表示电梯将会以规定的顺序在哪些楼层停下.电梯升高一层需要6秒,下降一层需要4秒.每次停下电 ...

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

    题意: 电梯初始状态停在第0层,给出电梯要接人的层数和层序号,计算接到所有人需要的时间,接完人后电梯无需回到1层(1层不是0层).电梯上升一层需要6秒,下降一层需要4秒,接人停留时间为5秒. AAAA ...

随机推荐

  1. jsp标签在spring boot中的关键用法

    <form:form modelAttribute="user" action="save" method="post" >// ...

  2. nginx+keepalived主从高可用配置

    上面有4台web服务器  我们实验条件限制,就开两台web服务器1.117  1.119 一.环境准备: 系统环境:CentOS 6.5 x86_64 Nginx版本:nginx v1.6.2 Kee ...

  3. 有四个数字能组成多少个互不相同的三位数 --Python

    有四个数字能组成多少个互不相同的三位数? num = 0 for i in range(1, 5): for j in range(1, 5): for k in range(1, 5): if i ...

  4. 工作总结--CTO(张王岩)File的使用

    名称     路径分隔符 pathSeparator   separator 构造器 文件名.路径名 getName()  getPath() getAbsolutePath()  getParent ...

  5. 用户字符串操作,这里面包括字符串的decode、encode、substract等等操作

    工具类描述:用户字符串操作,这里面包括字符串的decode.encode.substract等等操作 package cn.hgnulb; import java.io.UnsupportedEnco ...

  6. [转帖]阿里的JDK预热warmup过程

    预热warmup过程 https://blog.csdn.net/wabiaozia/article/details/82056520 Jwarmup 原理是记录上一次运行时已经变成native co ...

  7. SSH协议(1)-工作原理及过程

    转载. https://blog.csdn.net/cjx529377/article/details/77659199 SSH全称是Secure Shell,SSH协议是基于应用层的协议,为远程登录 ...

  8. WIN10更换无线网卡后WIFI无法正常启用

    这里根据自己经历提供几个方案: 首先我们要确定这两个地方正常(表示网卡能识别.驱动安装好:有无线开关没打开的朋友请出门右转): 方案一:万能的重启,不觉得麻烦的就多重启几遍.大力出奇迹! 方案二:然后 ...

  9. 题解 luoguP3554 【[POI2013]LUK-Triumphal arch】

    代码的关键部分 inline void dfs(int u,int fa) { ; for(int i=first[u]; i; i=nxt[i]) { int v=go[i]; if(v==fa)c ...

  10. C++ algorithm算法库

    C++ algorithm算法库 Xun 标准模板库(STL)中定义了很多的常用算法,这些算法主要定义在<algorithm>中.编程时,只需要在文件中加入#include<algo ...