pat1008. Elevator (20)
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<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)的更多相关文章
- PAT 1008. Elevator (20)
1008. Elevator (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The highest ...
- 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 ...
- 1008 Elevator (20分)
1008 Elevator (20分) 题目: The highest building in our city has only one elevator. A request list is ma ...
- 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)
The highest building in our city has only one elevator. A request list is made up with N positive nu ...
- 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 ...
- 【PAT甲级】1008 Elevator (20分)
1008 Elevator 题目: The highest building in our city has only one elevator. A request list is made up ...
- 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 ...
随机推荐
- markdown编辑器使用教程
网上的资料很多,我收集整理学习下. 我是下划线 *** 我是标题 我也是标题 ewq着重ewqe 列表1 列表2 我也是 我也是 有序列表 有序列表 //我是代码 int x=0; int y=x; ...
- Appium的常用定位方法
使用uiautomatorviewer.bat工具来找到属性定位元素,在SDK的tools目录下找到该工具,双击打开.左边框内展示app的界面元素,右上角框内展示元素的层级关系,右下角框内展示元素的属 ...
- Python3中简单的迭代器程序
1.迭代器程序(实现菲比那次数列并且可以抛出与接收异常) def fib(max): n,a,b = 0,0,1 while n < max: #print(b) yield b a,b = b ...
- vue 路由里面的 hash 和 history
对于 Vue 这类渐进式前端开发框架,为了构建 SPA(单页面应用),需要引入前端路由系统,这也就是 Vue-Router 存在的意义.前端路由的核心,就在于 —— 改变视图的同时不会向后端发出请求. ...
- 【bzoj1951】: [Sdoi2010]古代猪文 数论-中国剩余定理-Lucas定理
[bzoj1951]: [Sdoi2010]古代猪文 因为999911659是个素数 欧拉定理得 然后指数上中国剩余定理 然后分别lucas定理就好了 注意G==P的时候的特判 /* http://w ...
- ThinkPHP CURD 操作
Thinkphp CURD操作php中实例还对象即可操作 (目录) 1.Add 1 调式程序 3 调出显示页面Trace信息 3 Dump 的含义 4 2.数据库查询 4 1.直接使用字符串进行查找 ...
- jmeter+Jenkins性能测试自动化搭建
一.安装java.ant.maven 1.官网下载tar.gz包 2.解压相应的tar包 3.配置/etc/profile路径 4.source /etc/profile 使配置生效. 二.安装Jen ...
- String s String s=null和String s="a"区别
原文链接:https://www.cnblogs.com/ipetergo/p/6826909.htmlString s;和String s=null;和String s="a"; ...
- loj#6229 这是一道简单的数学题
\(\color{#0066ff}{ 题目描述 }\) 这是一道非常简单的数学题. 最近 LzyRapxLzyRapx 正在看 mathematics for computer science 这本书 ...
- opencv第三课,图像滤波
1.介绍 OpenCV图像处理技术中比较热门的图像滤波操作主要被分为了两大类:线性邻域滤波和非线性滤波.线性邻域滤波常见的有“方框滤波“,”均值滤波“和”高斯滤波“三种,二常见的非线性滤波主要是中值滤 ...