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<iostream>
#include<string>
#include<stdlib.h>
#include<vector>
#include<algorithm>
using namespace std; int main()
{
int n;
int current = ;
int sum = ;
cin >> n;
int num;
while (n--)
{
cin >> num;
if (num> current)
sum += (num - current) * + ;
else
sum += (current - num) * + ;
current = num;
}
cout << sum;
}
1008 Elevator (20 分)的更多相关文章
- 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 ...
- 【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 ...
- PAT (Advanced Level) Practice 1008 Elevator (20 分) (模拟)
The highest building in our city has only one elevator. A request list is made up with N positive nu ...
- 【PAT甲级】1008 Elevator (20 分)
题意: 电梯初始状态停在第0层,给出电梯要接人的层数和层序号,计算接到所有人需要的时间,接完人后电梯无需回到1层(1层不是0层).电梯上升一层需要6秒,下降一层需要4秒,接人停留时间为5秒. AAAA ...
- 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)
1008. Elevator (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The highest ...
- 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 ...
随机推荐
- IOS7下,alertView不能使用addSubview添加textField解决办法
UIAlertView *alertView1 = [[UIAlertView alloc] initWithTitle:@"Enter Form Name" message:@& ...
- jQuery插件select2跨域设置xhrFields参数
ajax跨越时默认不带cookie,如果需要带cookie调用,需要设置参数 xhrFields: { withCredentials: true },如: $.ajax({url : "h ...
- flask 密码加密 视频资料
https://www.bilibili.com/video/av53870541/?p=33 通过在数据模型中定义函数来实现加密 from werkzeug.security import gene ...
- 机器学习实用案例解析(1) 使用R语言
简介 统计学一直在研究如何从数据中得到可解释的东西,而机器学习则关注如何将数据变成一些实用的东西.对两者做出如下对比更有助于理解“机器学习”这个术语:机器学习研究的内容是教给计算机一些知识,再让计算机 ...
- 记一次华为eNSP设备网络项目基本配置过程
下图为综合项目示例图,详细命令见图下: 屏蔽垃圾信息undo terminal monitorundo terminal trappingundo terminal loggingundo termi ...
- activated钩子函数
activated钩子函数是在组件被激活后的钩子函数,mounted是不保证组件在document中,也就是组件还没有被激活,因此可以理解为activated执行在mounted之后. 在跳转传值时, ...
- [日志分析]Graylog2采集Nginx日志 主动方式
这次聊一下Graylog如何主动采集Nginx日志,分成两部分: 介绍一下 Graylog Collector Sidecar 是什么 如何配置 Graylog Collector Sidecar 采 ...
- consoleInfo 输出 数组套对象 不显示...的方法 序列化 再反序列化
consoleInfo (...args) { // console.info('this', this) const name = this.$options.name let outName = ...
- 【Weiss】【第04章】二叉搜索树例程
[二叉搜索树] 随机生成时平均深度为logN,平均插入.删除和搜索时间都是O(logN). 可能存在的问题是数据不均衡,使树单边生长,极端情况下变成类似链表,最坏插入.删除.搜索时间O(N) 写这个例 ...
- 使用AJAX实现用户名的唯一性校验(注册界面)-JAVA(新手)
(1)实现用户名的唯一性校验 所需要准备的: Servlet 注册界面的JSP 接口和实现类 所需要的接口和实现类: 接口: /* * 用户注册 * 账号的唯一性校验,需要传参(username) * ...