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>
#include<string>
#include<stdlib.h>
#include<vector>
#include<algorithm>
using namespace std; int main()
{
int n;
int current = ;
int sum = ;
cin >> n;
int num;
while (n--)
{
cin >> num;
if (num> current)
sum += (num - current) * + ;
else
sum += (current - num) * + ;
current = num;
}
cout << sum;
}

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

  1. 1008 Elevator (20分)

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

  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. 【PAT甲级】1008 Elevator (20分)

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

  4. PAT Advanced 1008 Elevator (20 分)

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

  5. 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 ...

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

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

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

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

  8. PAT 1008. Elevator (20)

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

  9. 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 ...

随机推荐

  1. swoft 上传图片到 阿里云oss aliyun-oss

    1.swoft  获取上传的文件 .官方文档上面没有看到 $files = $request->getUploadedFiles(); $file = $files['file']; 2.在模型 ...

  2. Canny检测算法与实现

    1.原理 图象边缘就是图像颜色快速变化的位置,对于灰度图像来说,也就是灰度值有明显变化的位置.图像边缘信息主要集中在高频段,图像锐化或检测边缘实质就是高通滤波.数值微分可以求变化率,在图像上离散值求梯 ...

  3. Mac OS X 10.13上 安装odoo 11.0开发环境

    0.准备假设homebrew已经安装好没安装的需要先安装,见下面链接http://brew.sh/ 1.安装PostgreSQL$ brew tap homebrew/services$ brew i ...

  4. 区间DP(力扣1000.合并石头的最低成本)

    一.区间DP 顾名思义区间DP就是在区间上进行动态规划,先求出一段区间上的最优解,在合并成整个大区间的最优解,方法主要有记忆化搜素和递归的形式. 顺便提一下动态规划的成立条件是满足最优子结构和无后效性 ...

  5. [POI2017]bzoj4726 Sadota?

    题目描述 离线题库请 题目描述 某个公司有\(n\)个人, 上下级关系构成了一个有根树.其中有个人是叛徒(这个人不知道是谁).对于一个人, 如果他 下属(直接或者间接, 不包括他自己)中叛徒占的比例超 ...

  6. go源码分析(一) 通过调试看go程序初始化过程

    参考资料:Go 1.5 源码剖析 (书签版).pdf 编写go语言test.go package main import ( "fmt" ) func main(){ fmt.Pr ...

  7. react 给选中的li添加样式(转载)

    路:使用事件委托,关键:获取到的index必须转为数字,因为它是字符串 handleClick = (e) => { const nodeName = e.target.nodeName.toU ...

  8. mysql & Tomcat使用问题记录

    mysql使用问题记录 1.mysql如何修改root密码 a.进入mysql安装目录b.登录 mysql -u root -pc.修改密码 mysql> SET PASSWORD FOR ro ...

  9. 6. concat_ws用法

    select  CONCAT_WS('-', e.audit_one_name, e.audit_second_name) from t_audit_item_name e  where e.id= ...

  10. 关于手机淘宝3.25bug我的一些思考与建议

    这两天被手淘ios版3.25bug刷屏了,影响还是挺大的,仅3.25日当天截止到下午5点在微博上的话题阅读量,已经突破8000万.给广大网友带来一次吃瓜盛宴.我们先简单回顾下这个bug的故事线: 我查 ...