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. Python3之切片及内置切片函数slice

       切片   取一个list或tuple的部分元素是非常常见的操作.比如,一个list L=[0,1,2,3,4,5,6,7,8,9] 取前3个元素,应该怎么做 笨方法,一个个列出来 >> ...

  2. iOS面试题超全!

    之前看了很多面试题,感觉要不是不够就是过于冗余,于是我将网上的一些面试题进行了删减和重排,现在分享给大家.(题目来源于网络,侵删) 1. Object-c的类可以多重继承么?可以实现多个接口么?Cat ...

  3. maven执行过程中抛出的各类异常信息

    价值 各类异常信息分类 举例 maven源代码的模块maven-core里的各类*Exception命名的class包含里,maven执行过程中打印的各类异常日志内容 比如如下错误 错误信息分别来自( ...

  4. 给.Net Core添加Swagger实现接口文档自动生成

    1.添加Nuget相关引用 Swashbuckle.AspNetCore

  5. Bilibili用户需求分析报告

    一.产品简介 哔哩哔哩(英文名称:bilibili,简称B站)是国内知名的弹幕视频分享站,也是国内领先的年轻人文化社区 二.用户需求分析 (一)目标用户 根据百度指数,bilibili的主要用户遍布沿 ...

  6. Vue项目过程中遇到的小问题

    1.给router-link添加点击事件 <router-link to="" @click.native=""></router-link& ...

  7. 最新 锐之旗java校招面经 (含整理过的面试题大全)

    从6月到10月,经过4个月努力和坚持,自己有幸拿到了网易雷火.京东.去哪儿.锐之旗等10家互联网公司的校招Offer,因为某些自身原因最终选择了锐之旗.6.7月主要是做系统复习.项目复盘.LeetCo ...

  8. idea查看接口或类的所有方法

    第一种: 显示结果: 第二种: 点击左显示栏的Structure: 第三种:ctrl+f12,有的电脑可能需要加fn键

  9. subplot()一个窗口画多个图

    import matplotlib.pyplot as plt plt.subplot(m,n,p) m,n表示一个窗口上显示m行n列 p表示正在处理第p个区域的部分(区域编号从左到右,从上到下) f ...

  10. JavaSE基础(一)--初识Java

    Java 简介 Java是由Sun Microsystems公司于1995年5月推出的Java面向对象程序设计语言和Java平台的总称.由James Gosling和同事们共同研发,并在1995年正式 ...