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<stdio.h>
int floor[100];
int main(){
int n;
scanf("%d", &n);
if(n==0) return 0;
int i;
int costTime = n * 5;
for( i =0; i< n; i++){
scanf("%d", &floor[i]);
if(i >= 1){
if(floor[i] > floor[i-1]) costTime += (floor[i]-floor[i-1])*6;
else if(floor[i] < floor[i-1]) costTime += (floor[i-1]-floor[i])*4;
}
else{
costTime += floor[i]*6;
}
}
printf("%d\n", costTime);
return 0;
}
分享到:
相关推荐
elevator.js 是一个 "back to top" 按钮,即点击 "back to top" 按钮即可缓慢的返回网页顶部。 示例: [removed] // Elevator script included...elevator.elevate(); [removed] 标签:elevator
elevator.exe
使用java语言实现的elevator模拟程序
电梯群控系统服务质量和运行效能评估软件设计与实现 建立了电梯客流到达模型,然后建立了6种电梯群调度模型
模拟器电梯 模拟建筑物中电梯的使用
algorithm that has been designed by ThyssenKrupp Elevator Company for the express purpose of evacuating mid to high rise buildings and demonstrates the reduced time of egress as opposed to traditional...
this is the java code for elevator which can be applied on elevator operation.
elevator_sim.pro.user
自己编的双电梯软件模拟系统,通过交互的按键界面和状态栏,模拟双电梯的运行状况
Elevator.dsp
STM32 mini开发板,实现触摸电梯升降小程序
简单电梯模拟程序,一个.c文件,版权所有,请于24小时内删除,勿用于商业用途
用cocos2d-x引擎开发的C++电梯模拟调度程序,有可视化的界面。
实现9层电梯控制 功能如下:1,先假设没上楼之前,楼层运行看不到(没图形),可以当做随机看待。 2。当在某层按电梯开关后,在屏幕显示电梯停到该指定楼层的图形状态。 3。随后可以按想去的楼层,在屏幕显示电梯...
python库,解压后可用。 资源全名:stix2_elevator-1.0.0-py2.py3-none-any.whl
采用verilog写的四层电梯控制程序,有相应的图片,报告,容易理解
Java电梯系统,电梯运行状态:从电梯启动时刻,到电梯运动停止时的运行状态,包括上行(UP)和下行(DOWN)状态。此状态电梯速度大于0。(启动时刻,运行停止时刻)。 b)电梯开关门状态:电梯静止时,从门打开时刻(门...
this is a elevator simulator,winform,csharp,and ds