1008. Elevator (20)

时间限制
400 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

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<stack>
#include<cstring>
#include<iostream>
using namespace std;
int main(){
int n,b=,cur,t=;
scanf("%d",&n);
while(n--){
scanf("%d",&cur);
if(cur>b){
t+=(cur-b)*+;
}
else{
t+=(b-cur)*+;
}
b=cur;
}
printf("%d\n",t);
return ;
}

pat1008. Elevator (20)的更多相关文章

  1. PAT 1008. Elevator (20)

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

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

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

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

  4. 1008 Elevator (20分)

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

  5. PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642 题目描述: The highest building in our city has ...

  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. 1008 Elevator (20)(20 point(s))

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

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

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

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

随机推荐

  1. [Study notes] To programing RGBD-SLAM together from Gaoxiang

    Solve CMake Error in CMakeLists.txt (FIND_PAKAGE): CMake Error at src/CMakeLists.txt:5 (FIND_PACKAGE ...

  2. winform 动态添加控件及事件

    for (int i = 0; i < 4; i++) { Button btn = new Button(); //btn.Name = dt.Rows[i]["ANDON_CONT ...

  3. CF70D(动态凸包)

    CF70D(动态凸包) 给出q(<=1e5)个询问,每次在加上一个点,维护凸包,或者询问某个点是否在凸包内(在边上也算). 听说可以用cdq做--但是并不会.我等蒟蒻只会用平衡树做. 首先,假设 ...

  4. tcp设置超时重传

    TCP超时和重传的基础是怎样根据给定连接RTT设置RTO,若TCP先于RTT开始重传,可能会在网络中引入不必要的重复数据,反之,若延迟至远大于RTT的间隔发送重传数据,整体网络利用率会随之下降.由于R ...

  5. ThreadLocalRandom原理

    原文链接:https://www.jianshu.com/p/9c2198586f9b 2.2. 并发包中ThreadLocalRandom类原理剖析 ThreadLocalRandom类是JDK7在 ...

  6. P4213 【模板】杜教筛(Sum)

    \(\color{#0066ff}{题 目 描 述}\) 给定一个正整数\(N(N\le2^{31}-1)\) 求 \(\begin{aligned} ans_1=\sum_{i=1}^n\varph ...

  7. socket套接字基本概念

    int socket()函数创建的是套接字socket,返回的是socket描述符(套接字描述符),其实就是文件描述符,socket(套接字)其实就是文件 socket()创建了套接字(文件),只是开 ...

  8. linux1--常用命令

    1.目录结构 2./etc:系统配置文件存放地 比如你的wsgi的配置文件,nginx 3./usr 应用程序存放地 比如你的jdk应用程序存放地 4./root 系统管理员root的家目录 4.1像 ...

  9. mybatis逆向工程工具

    mybatis逆向工程 package com.cxy; import java.io.File; import java.util.*; import org.mybatis.generator.a ...

  10. 异步解决方案(三)Promise

    首先建议大家先看看这篇博文,这是我看过的最清晰给力的博文了: https://www.cnblogs.com/lvdabao/p/es6-promise-1.html 附赠一篇笑死我了的博客,加入有一 ...