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. jQuery的Validate插件

    http://www.runoob.com/jquery/jquery-plugin-validate.html 项目中的:: $(function () { $('#createDepartment ...

  2. WebStorm设置Themes

    1.首先去 http://www.phpstorm-themes.com/  选择你喜欢的主题,保存对应主题的xml文件到你本地 2.打开C:\Users\Administrator\.WebStor ...

  3. Service Fabric 群集在Service Replica过多的情况下报错问题

    首先 Service Fabric 群集是正常的,部署一些服务过后也能正常运行,但一旦部署的服务过多后,且每个服务不止一个Partition,就有可能让群集状态为Error,但其实服务还是在正常运行的 ...

  4. 动态合并GridView数据行DataRow的列

    前段时间,Insus.NET一直在演示GridView控件Header头行或列:<动态变更GridView控件列名>和<动态合并或定制GridView控件Header头某些列> ...

  5. ubuntu - 14.04,如何让从托盘消失的输入法图标再次显示出来?

    ubuntu14.04,我也不知道怎么搞的,突然输入法图标就从托盘上消失了,这可真太不方便了,不知道自己当前是否正在使用输入法,怎么能让输入法图标再次显示在托盘上? 解决办法:确保你的“系统设置”中有 ...

  6. UI控件相关宏定义

    1.显示设置 1.1 view圆角和边框 /** 设置view圆角和边框 */ #define kViewBorderRadius(View, Radius, Width, Color)\ \ [Vi ...

  7. [51nod1190]最小公倍数之和V2(莫比乌斯反演)

    题解 传送门 题解 我是真的不明白这玩意儿是怎么跟反演扯上关系的-- 首先 \[ \begin{align} ans &=b\sum_{d|b}{1\over d}\sum_{i=a}^{b} ...

  8. tomcat8性能优化

    在tomcat/catalina.sh中加入下面的配置,内存要根据机器实际情况配置,如果配置内存太大了有可能机器很慢. JAVA_OPTS="-server -Xms512m -Xmx512 ...

  9. Mysql INNER JOIN

    1.MySQL INNER JOIN子句将一个表中的行与其他表中的行进行匹配,并允许从两个表中查询包含列的行记录. 2.INNER JOIN子句是SELECT语句的可选部分,它出现在FROM子句之后. ...

  10. Unity 使用小技巧

    本文介绍我遇到过我Unity使用小技巧,有了这些技巧,项目做起来,溜得飞起 1.快速设置相机的位置 2.固定面板