PAT Advanced 1008 Elevator (20 分)
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 分)的更多相关文章
- PAT Advanced 1008 Elevator (20) [数学问题-简单数学]
题目 The highest building in our city has only one elevator. A request list is made up with N positive ...
- PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642
PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642 题目描述: The highest building in our city has ...
- 1008 Elevator (20分)
1008 Elevator (20分) 题目: The highest building in our city has only one elevator. A request list is ma ...
- PAT 甲级 1008 Elevator (20)(代码)
1008 Elevator (20)(20 分) The highest building in our city has only one elevator. A request list is m ...
- 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 ...
- 【PAT甲级】1008 Elevator (20分)
1008 Elevator 题目: The highest building in our city has only one elevator. A request list is made up ...
- 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 ...
- PAT 甲级 1008 Elevator (20)(20 分)模拟水题
题目翻译: 1008.电梯 在我们的城市里,最高的建筑物里只有一部电梯.有一份由N个正数组成的请求列表.这些数表示电梯将会以规定的顺序在哪些楼层停下.电梯升高一层需要6秒,下降一层需要4秒.每次停下电 ...
- 【PAT甲级】1008 Elevator (20 分)
题意: 电梯初始状态停在第0层,给出电梯要接人的层数和层序号,计算接到所有人需要的时间,接完人后电梯无需回到1层(1层不是0层).电梯上升一层需要6秒,下降一层需要4秒,接人停留时间为5秒. AAAA ...
随机推荐
- 2019年12月4日 Linux总结
System V init运行级别 systemd目标名称 作用 0 runlevel0.target,poweroff.target 关机 1 runlevel1.target,poweroff.t ...
- iostat的坑
简单使用iostat查询io使用量,会让你看不懂所以然,因为很多人疏忽了这个命令查到的结果根本不是实际值,需要注意的是一句话: “第1次采样信息与单独执行iostat的效果一样,为从系统开机到当前执行 ...
- 微信jsapi开发应用实例并记录下错误信息
虽然大家已经有实例,但还是要根据自己的项目更改 在这里需要注意的几点 也是常常报错的 1.页面必须是UTF8(已经json不认gbk,所以会提醒 -1调用支付JSAPI缺少参数APPID 这是编码引起 ...
- Ie浏览器请求400错误,谷歌火狐等浏览器正常请求.
做项目的时候,遇到一个小的问题.一个location.href="请求的url"在其它浏览器上是可以正常请求的.但是在ie浏览器上确出现奇怪的http请求400错误,我们先来对于h ...
- 多年经验【Parallels Desktop14.0.1 永久激活 】版 推荐苹果mac 虚拟机pmg序列号
parallels desktop 14 mac 激活码 parallels 13免费密钥 parallels desktop 14 激活码 很多用 MAC 的朋友发现平时离不开 W ...
- Mac10.14.6安装并破解PyCharm
之前安装了PyCharm的Community版本, 用了半天之后发现好多功能都没有, 于是准备安装专业版然后破解. 安装包直接去官网下载, 不多说. 破解补丁的下载地址如下: 链接:https://p ...
- openlayers集成到vue开发
openlayer初步加载地图 vue项目搭好后,直接用node js安装ol, 安装好后可以看看安装的版本:我用的是5..2的版本 然后看官网相对应版本的文档,都是英文文档; 官方文档: ht ...
- Scala调用Kafka的生产者和消费者Demo,以及一些配置参数整理
kafka简介 Kafka是apache开源的一款用Scala编写的消息队列中间件,具有高吞吐量,低延时等特性. Kafka对消息保存时根据Topic进行归类,发送消息者称为Producer,消息接受 ...
- laravel中间件的实现原理
中间件的实现原理 运用 array_reduce 以及 call_user_func 实现 interface Middleware { public static function handle(C ...
- Centos7.3安装nexus12.1
nexus.12.1-01的安装 1.下载nexus 2.上传到服务器/root/ 3.解压 t ...