A1008. Elevator
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<iostream>
using namespace std;
int main(){
int N, temp, ans = , floor = ;
scanf("%d", &N);
for(int i = ; i < N; i++){
scanf("%d", &temp);
if(floor < temp){
ans += (temp - floor) * ;
ans += ;
floor = temp;
}else if(floor == temp){
ans += ;
}else{
ans += (floor - temp) * ;
ans += ;
floor = temp;
}
}
printf("%d", ans);
cin >> N;
return ;
}
A1008. Elevator的更多相关文章
- PAT甲级——A1008 Elevator
The highest building in our city has only one elevator. A request list is made up with N positive nu ...
- PTA A1007&A1008
第四天 A1007 Maximum Subsequence Sum (25 分) 题目内容 Given a sequence of K integers { N1, N2, ..., NK }. A ...
- HDOJ 1008. Elevator 简单模拟水题
Elevator Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su ...
- poj[2392]space elevator
Description The cows are going to space! They plan to achieve orbit by building a sort of space elev ...
- Design Elevator
From: https://discuss.leetcode.com/topic/89/write-elevator-program-using-event-driven-programming/9 ...
- PAT (Advanced Level) Practise:1008. Elevator
[题目链接] The highest building in our city has only one elevator. A request list is made up with N posi ...
- Pair Project: Elevator Scheduler [电梯调度算法的实现和测试]
作业提交时间:10月9日上课前. Design and implement an Elevator Scheduler to aim for both correctness and performa ...
- POJ2392Space Elevator(贪心+背包)
Space Elevator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9970 Accepted: 4738 De ...
- hdu 1008 Elevator
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Description The hig ...
随机推荐
- Uniform Generator HDU1014
题意 给你公式seed(x+1) = [seed(x) + STEP] % MOD ,输入step和mod, 问你是否可以从第一项0,算到mod,它们是否都不同 是 good choice 否则 ba ...
- 个人博客作业Week2 是否需要有代码规范
问题:是否需要有代码规范 对于是否需要有代码规范,请考虑下列论点并反驳/支持: 1.这些规范都是官僚制度下产生的浪费大家的编程时间.影响人们开发效率, 浪费时间的东西. 2.我是个艺术家,手艺人,我有 ...
- node基础 npm、module、exports、require
module 模块.包:可以认为是一个代码包,package,提供特定的功能(暴露给外界接口,让外界调用) exports 输出.导出:导出模块中的各种类型的变量,以及各种方法,导出之后,才可以被外界 ...
- PAT L3-021 神坛
https://pintia.cn/problem-sets/994805046380707840/problems/994805046577840128 在古老的迈瑞城,巍然屹立着 n 块神石.长老 ...
- SQLserver 使用网络驱动器恢复数据库
1. 公司内有多台虚拟机,因为公司提供出来的机器 硬盘总是不够大...所以想到了使用 映射网络驱动器的方式进行备份恢复工作. 学到的方法主要如下: 0. 首先打开sqlcmd 启动命令行界面 1. ...
- ubuntu 下搭建redis和php的redis的拓展
系统环境: 腾讯云服务器, ubuntu16.0.4.4 ,php7.0 一.安装redis服务 sudo apt-get install redis-server 安装好的redis目录在 /e ...
- php的一些算法题
1.有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,请编程输出两年内每个月的兔子总数为多少? <?php function getRes ...
- Python 2和Python 3的编码问题
在Python2中,字符串无法完全地支持国际字符集和Unicode编码.为了解决这种限制,Python2对Unicode数据使用了单独的字符串类型.要输入Unicode字符串字面量,要在第一个引号前加 ...
- idea for mac 最全快捷键整理
一.Mac键盘符号和修饰键说明 ⌘ Command ⇧Shift ⌥ Option ⌃ Control ↩︎ Return/Enter ⌫ Delete ⌦ 向前删除键(Fn+Delete) ↑ 上箭 ...
- python之Oracle操作(cx_Oracle)
python可通过使用cx_Oracle模块对Oracle数据库进行操作.首先,需要下载cx_Oracle模块,下载地址:https://pypi.python.org/pypi/cx_Oracle/ ...