SDAU课程练习--problemG(1006)
题目描述
Problem Description 
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
There are multiple test cases. Each case contains a positive integer N, followed by N positive numbers. All the numbers in the input are less than 100. A test case with N = 0 denotes the end of input. This test case is not to be processed.
Output
Print the total time on a single line for each test case.
Sample Input
1 2
3 2 3 1
0
Sample Output
17
41
题目大意
简单的水题,电梯上升一层楼需要6s,下降需要4s,到达目的楼层后停留5s。给出目的楼层的列表。求需要的时间。 
使用模拟法,模拟电梯的运行过程求得总时间。
AC代码
#include<iostream>#include<stdio.h>using namespace std;int main(){//freopen("date.in","r",stdin);//freopen("date.out","w",stdout);ios::sync_with_stdio(false);int N,m,sum,tem;while(cin>>N&&N!=0){sum=0;tem=0;for(int i=0;i<N;i++){cin>>m;if(m>tem)sum+=(6*(m-tem));else sum+=(4*(tem-m));tem=m;}cout<<sum+N*5<<endl;}}
SDAU课程练习--problemG(1006)的更多相关文章
- SDAU课程练习--problemQ(1016)
		
题目描述 FJ is surveying his herd to find the most average cow. He wants to know how much milk this 'med ...
 - SDAU课程练习--problemO(1014)
		
题目描述 Before bridges were common, ferries were used to transport cars across rivers. River ferries, u ...
 - SDAU课程练习--problemB(1001)
		
题目描述 There is a pile of n wooden sticks. The length and weight of each stick are known in advance. T ...
 - SDAU课程练习--problemA(1000)
		
题目描述 The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape i ...
 - SDAU课程练习--problemC
		
题目描述 Here is a famous story in Chinese history. "That was about 2300 years ago. General Tian Ji ...
 - SDAU课程练习--problemE
		
problemE 题目描述 "今年暑假不AC?" "是的." "那你干什么呢?" "看世界杯呀,笨蛋!" "@ ...
 - SpringMVC框架  课程笔记
		
SpringMVC框架 课程笔记 第0章 SpringMVC框架的核心内容 1.SpringMVC 概述 2.SpringMVC 的 HelloWorld 3.使用 @RequestMapping 映 ...
 - MyBatis框架   课程笔记
		
MyBatis框架 课程笔记 第1章 MyBatis简介 1.1 MyBatis历史 1)MyBatis是Apache的一个开源项目iBatis, 2010年6月这个项目由Apache Softw ...
 - .NET 提升教育 第一期:VIP 付费课程培训通知!
		
为响应 @当年在远方 同学的建议,在年前尝试进行一次付费的VIP培训. 培训的课件:点击下载培训周期:10个课程左右,每晚1个半小时培训价格:1000元/人.报名方式:有意向的请加QQ群:路过秋天.N ...
 
随机推荐
- VBS虚拟键码
			
1 VK_LBUTTON 鼠标左键 2 VK_RBUTTON 鼠标右键 3 VK_CANCEL Ctrl+Break(通常不需要处理) 4 VK_MBUTTON 鼠标中键 8 VK_BACK Back ...
 - hdu_3518_Boring counting(后缀数组)
			
题目链接:hdu_3518_Boring counting 题意: 给你一个字符串,让你找不重叠且出现大于1次以上的字串个数 题解: 后缀数组height数组的应用,我们枚举字串的长度,然后将heig ...
 - CentOS 7 BIND 主从搭建
			
主机 10.2.0.15 从机 10.2.0.14 1 主机配置$vim /etc/named.bodani.com.zones zone"bodani.com" IN { typ ...
 - Hadoop2.6.0  动态增加节点
			
本文主要从基础准备,添加DataNode和添加NodeManager三个部分详细说明在Hadoop2.6.0环境下,如何动态新增节点到集群中. 基础准备 在基础准备部分,主要是设置hadoop运行的系 ...
 - 阿里云Linux挂载数据盘
			
Linux 系统挂载数据盘 适用系统:Linux(Redhat , CentOS,Debian,Ubuntu) * Linux的云服务器数据盘未做分区和格式化,可以根据以下步骤进行分区以及格式化 ...
 - Ajax及select级联
			
cascade.jsp(Test/WebContent/jsp/cascade.jsp): <%@ page language="java" contentType=&quo ...
 - IIS express 7.5 设置默认文档
			
在C:\Users\[电脑用户名]\Documents\IISExpress\config 下面有个applicationhost.config文件,打开文件找到<system.webServe ...
 - 使用VS软件打开网站在浏览器浏览的方法
			
1.用VS软件打开网站之后,先检查网站是否使用IIS Express开发 2.若不是,则切换成使用IIS Express开发 3.检查项目使用的托管管道模式设置为经典模式了没有 4.最后选择“在浏览器 ...
 - 转  EXPDP ORA-39095 ORA-3909 错误
			
今天帮同事在测试库上导出两张表,第一张表大小为30M,第二章表大小为7G,以下是expdp语法 expdp tranuser/******** parallel=4 content=data_only ...
 - Basically Speaking
			
Basically Speaking Time Limit: 2 Sec Memory Limit: 200 MB Submit: 19 Solved: 11 [Submit][Status][W ...