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 ...
随机推荐
- 【转载】固态硬盘的S.M.A.R.T详解
文章来源于: 瑞耐斯存储技术 兵哥写这篇文章,是因为在测试的过程中看到了 SSD存在偶尔有性能下降的情况,经分析为S.M.A.R.T命令所导致,虽然这种情况看似不严重,但如果应用在诸如数据采集等关键性 ...
- Session之Config配置
<sessionState mode="Off|InProc|StateServer|SQLServer" cookieless="true|false" ...
- Redis数据"丢失"讨论及规避和解决的几点总结
Redis大部分应用场景是纯缓存服务,请求后端有Primary Storage的组件,如MySQL,HBase;请求Redis的键未命中,会从primary Storage中获取数据返回,同时更新Re ...
- keepalived概述
一.HA集群中的相关术语 1.节点(node) 运行HA进程的一个独立主机,称为节点,节点是HA的核心组成部分,每个节点上运行着操作系统和高可用软件服务,在高可用集群中,节点有主次之分,分别称之为主节 ...
- 理解Vue 2.5的Diff算法
DOM"天生就慢",所以前端各大框架都提供了对DOM操作进行优化的办法,Angular中的是脏值检查,React首先提出了Virtual Dom,Vue2.0也加入了Virtual ...
- 必应词典案例分析——个人博客作业week3
案例分析 ——必应词典客户端 软件缺陷常常又被叫做Bug,即为计算机软件或程序中存在的某种破坏正常运行能力的问题.错误,或者隐藏的功能缺陷. 缺陷的存在会导致软件产品在某种程度上不能满足用户的需要.I ...
- 20135316王剑桥Linux内核学习记笔记第七周
20135316王剑桥<Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC 1000029000 一.可执行程序是怎么得来的? 编译 ...
- C# wkhtmltopdf 将html转pdf(详解)
https://www.cnblogs.com/louby/p/905198.html转自,看文章只放了代码看起来云里雾里的,在此做些解析 使用说明: 1.首先呢,得安装下软件,地址下面有链接,文件里 ...
- idea 设置注释
idea和eclipse的注释还是有一些差别的. idea: 类头注释:打开file->setting->Editor->Filr and Code Templates->In ...
- 理解java的三大特性之继承
学习来源:http://www.cnblogs.com/chenssy/p/3354884.html default 默认权限(包权限-同一个包可以访问) private 私有(类内部可以使用,继承的 ...