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 pre = , now,sum = * N;//上一次停留在哪?现在要去的楼层,时间初始为要在 每一层的总停留时间
for (int i = ; i < N; ++i)
{
cin >> now;
if ((now - pre) > )//上
sum += (now - pre) * ;
else if ((now - pre) < )//下
sum += (pre - now) * ;
pre = now;//更新楼层
}
cout << sum << endl;
return ;
}

PAT甲级——A1008 Elevator的更多相关文章

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

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

  2. PAT 甲级 1008 Elevator

    https://pintia.cn/problem-sets/994805342720868352/problems/994805511923286016 The highest building i ...

  3. PAT甲级——1008 Elevator

    PATA1008 Elevator The highest building in our city has only one elevator. A request list is made up ...

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

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

  5. PAT甲级题解(慢慢刷中)

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  6. PAT甲级代码仓库

    大道至简,知易行难.希望能够坚持刷题. PAT甲级真题题库,附上我的代码. Label Title Score Code Level 1001 A+B Format 20 1001 * 1002 A+ ...

  7. PAT甲级1131. Subway Map

    PAT甲级1131. Subway Map 题意: 在大城市,地铁系统对访客总是看起来很复杂.给你一些感觉,下图显示了北京地铁的地图.现在你应该帮助人们掌握你的电脑技能!鉴于您的用户的起始位置,您的任 ...

  8. PAT甲级1127. ZigZagging on a Tree

    PAT甲级1127. ZigZagging on a Tree 题意: 假设二叉树中的所有键都是不同的正整数.一个唯一的二叉树可以通过给定的一对后序和顺序遍历序列来确定.这是一个简单的标准程序,可以按 ...

  9. PAT甲级1123. Is It a Complete AVL Tree

    PAT甲级1123. Is It a Complete AVL Tree 题意: 在AVL树中,任何节点的两个子树的高度最多有一个;如果在任何时候它们不同于一个,则重新平衡来恢复此属性.图1-4说明了 ...

随机推荐

  1. Rsync 参数

    # rsync -v, --verbose 详细模式输出 -q, --quiet 精简输出模式 -c, --checksum 打开校验开关,强制对文件传输进行校验 -a, --archive 归档模式 ...

  2. 502Bad Gateway

    502 bad gateway,错误的网关的原因 连接超时,我们向服务器发送请求,由于服务器当前链接太多,导致服务器方面无法给予正常的响应,产生此报错,最好去服务器上找原因. 性能测试常见,可能是由于 ...

  3. caffe安装 总结

    用的是matlab2018a,搞了一天 ubuntu 系统下的Caffe环境搭建 https://blog.csdn.net/hjimce/article/details/48781693 caffe ...

  4. 让er studio 生成带说明的sql

    一直使用er studion 来建数据库的模型图. 用了几年苦于 erstudion 不能生成带说明注释的sql 语句,每次生成实体之后都要自己去加注释. 今天根据外国朋友的资料找到了办法 需要自己建 ...

  5. 【JZOJ6354】最短路(tiring)

    description analysis 显然边权有变化规律\(x,{1\over{x-1}},{x-1\over x},x,...\) 于是把一个点拆成三个点,分别表示步数到除\(3\)余\(0,1 ...

  6. day21 生成器,列表解析,三元表达式

    Python之路,Day9 = Python基础9 判断可迭代对象和迭代器 from collections import Iterable, Iterator # 导入模块功能,用来判断对象是否为I ...

  7. thinkphp url大小写

    系统默认的规范是根据URL里面的模块名.控制器名来定位到具体的控制器类的,从而执行控制器类的操作方法. 以URL访问 http://serverName/index.php/Home/Index/in ...

  8. ajax跨域获取网站json数据

    由于自己的公司的项目需要调用视频地址 1:当为链接时:直接在播放器用数据库查找的地址 2:当为外部链接时:直接用window.location.href('数据库查找的地址') 3:当为H5链接时:使 ...

  9. 应用程序正常初始化(0xc0150002)失败的终极解决方案

    转自VC错误:http://www.vcerror.com/?p=62 最近做一个项目写了一个VC6下的MFC程序,结果传到别人的机子上(WIN7)出现了应用程序正常初始化(0xc0150002)失败 ...

  10. 豌豆荚Redis集群方案:Codis

    Codis简介 Codis是一个分布式Redis解决方案,对于上层的应用来说,连接到CodisProxy和连接原生的RedisServer没有明显的区别(不支持的命令列表),上层应用可以像使用单机的R ...