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<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm> using namespace std; int main() {
long long int sum=0;
int n; while(scanf("%d",&n)!=EOF) {
int a[10005]= {0};
sum=5*n;
scanf("%d",&a[0]);
sum+=6*a[0];
for(int t=1; t<n; t++) {
scanf("%d",&a[t]);
if(a[t]-a[t-1]>0) {
sum+=(a[t]-a[t-1])*6;
} else {
sum+=abs(a[t]-a[t-1])*4;
}
}
cout<<sum<<endl;
}
return 0;
}

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

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

  6. 1008 Elevator (20 分)

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

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

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

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

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

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

  10. PAT 1008. Elevator (20)

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

随机推荐

  1. SeekBar滑动时,progress数值不连续

    问题描述 logcat 你是否也遇见过这样的情况,SeekBar的进度不连续 这是我在做一个编辑图片的APP时,观察我打印的log,发现progress不是连续的 这时候可能就有人问:是你代码写的不对 ...

  2. 14、Java文件操作stream、File、IO

    1.文件操作涉及到的基本概念 File File类 是文件操作的主要对象中文意义就是 文件 顾名思意 万物皆文件,在计算上看到的所有东西都是文件保存,不管是你的图片.视频.数据库数据等等都是按照基本的 ...

  3. MySQL百万数据查询优化

    问题来源: 在查询统计的业务中做了一个小型的每隔一分钟的统计服务,实现1分钟,5分钟,1小时,2小时,一天,三天,一月,3月,一年的级联统计.前期数据来源表数据,以及生成的统计表数据都少; 数月之后, ...

  4. XCTF-WEB-高手进阶区-NaNNaNaNNaN-Batman-笔记

    上来直接百度先搜下Batman -_-|| 不存在的传令兵么 本身是下载下来了一个文件web100 打开发现是如下内容 可以看出这个是个脚本语言,因此尝试修改后缀为html,发现是一个OK框 现在是想 ...

  5. 2020-04-11:A系统联机同步调用B系统(A和B不是同一公司系统,不能用分布式事务),如何保证系统间数据准实时一致性(设计思路即可)?提醒:需要考虑调用超时、并发、幂等、反交易先到等问题

    福哥答案2020-04-12: 可参考微信支付和支付宝支付.

  6. Css 图片自适应

    设置 CSS .container{ overflow:auto; } img{ width:100%; height:auto; overflow:hidden; } 设置 template < ...

  7. windows安装msys2 mingw64

    msys2包含mingw32和mingw64 步骤1 首选安装msys64 链接:https://pan.baidu.com/s/1l9Zfm4TE1Gg3c7tkaH6KeQ 安装到指定目录 步骤2 ...

  8. 生成对抗网络GAN介绍

    GAN原理 生成对抗网络GAN由生成器和判别器两部分组成: 判别器是常规的神经网络分类器,一半时间判别器接收来自训练数据中的真实图像,另一半时间收到来自生成器中的虚假图像.训练判别器使得对于真实图像, ...

  9. .NET 跨平台框架Avalonia UI: 填坑指北(一):熟悉UI操作

    Avalonia 是一个跨平台的 .NET UI 框架,支持 Windows.Linux.Mac OSX... (以及Android  IOS soon..) 本篇主要介绍Avalonia开发过程和L ...

  10. Who Am I? Personality Detection based on Deep Learning for Texts 阅读笔记

    文章目录 源代码github地址 摘要 2CLSTM 过程 1. 词嵌入 2. 2LSTM处理 3. CNN学习LSGCNN学习LSG 4. Softmax分类 源代码github地址 https:/ ...