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 ...
随机推荐
- 多用户ATM机(面向对象编程)
let readline = require('readline-sync'); // 清屏函数 let clear = () => process.stdout.write(process.p ...
- visual2013 的 MVC 4中连接数据库报错解决方案
win7 64位安装vs2013后连接远程数据库出现下面的问题:A first chance exception of type 'System.AccessViolationException' ...
- kuangbin专题K(next数组)
题目链接: https://vjudge.net/contest/70325#problem/K 题意: 给出一个字符串 str, 求 str 的所有前缀总共出现的次数. 思路: 先求一次 next ...
- django 学习之DRF (一)
Django框架基础DRF-01 前后端分离介绍 1.前后端不分离图解 2.前后端分离图解 3.为什么要学习DRF DRF可以帮助我们开发者快速的开发⼀个依托于Django的前后后端分离 ...
- 10.20 olinr
感谢olinr提供md文件 免得我整理格式了 1.求助 (help.cpp/c/pas) [问题背景] 马上就要noip了,lrt同志\(\displaystyle\begin{vmatrix}\te ...
- kuangbin专题十二 HDU1260 Tickets (dp)
Tickets Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Sub ...
- thinkphp 3.0 核心函数U的一个致命bug
最近在玩thinkphp,感觉内置函数 U 挺强大的! 传递多个参数时,出乱子了(window环境下,xampp) 例如 echo U('Blog/cate',array('cate_id'=> ...
- pre 标签 防止 其撑开 div...
pre 里面 的内容如果不换行,会导致 div 横向 出现 滚动条...加入下列 css可解决! pre{ white-space: pre-wrap; word-wrap: break-word; ...
- Ueeidor 使用
setContent 要放在 ue.read(function(){ })中... js 字符串参数不要忘记 引号.....而且最好是单引号!!!
- WebServcies 调用方法异常:System.Web.HttpRequestValidationException: 从客户端中检测到有潜在危险的 Request.Form 值。
我在做WebServcies时,页面调试,报类了下面这样的错误信息: System.Web.HttpRequestValidationException: 从客户端(checkXML="&l ...