hdu 1008 Elevator
来源:互联网 发布:vpn提供商 windows内置 编辑:程序博客网 时间:2024/06/05 00:19
Elevator
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 35862 Accepted Submission(s): 19567
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.
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 23 2 3 10
Sample Output
1741
Author
ZHENG, Jianqiang
Source
ZJCPC2004
程序如下(已AC):
#include<stdio.h>
int main()
{
int n,num,i,t,begin;
while(scanf("%d",&n)&&n!=0)
{
begin=0;
t=0;
for(i=0;i<n;i++)
{
scanf("%d",&num);
if(num>=begin)
{
t=t+(num-begin)*6+5;
begin=num;
}
else
{
t=t+(begin-num)*4+5;
begin=num;
}
}
printf("%d\n",t);
}
return 0;
}
- HDU 1008 Elevator
- hdu 1008Elevator
- HDU 1008 Elevator
- HDU 1008 Elevator
- hdu 1008 elevator 水
- HDU 1008 Elevator
- Hdu 1008 - Elevator
- HDU 1008 Elevator
- HDU--1008--Elevator
- hdu 1008 Elevator
- HDU-1008 Elevator
- HDU 1008 Elevator
- hdu 1008 Elevator
- Hdu--1008--Elevator
- hdu 1008 Elevator
- hdu 1008 Elevator
- hdu-1008-Elevator
- hdu 1008 Elevator
- 证明:一个有n个结点的非空二叉树的高度至少为lgn
- Cascading Each Pipe 使用
- 技术真的就不是那么重要了
- 嵌入式开发做什么
- leetcode之 median of two sorted arrays
- hdu 1008 Elevator
- 易语言中 内存报错 之 自定义数据类型
- 地图投影
- 如何用Visual Studio开发iOS、Android应用
- 用函数输出星星
- 常用的SQL语句
- 修改输入设备状态
- 角色权限管理系统(角色功能授权)
- 星号图1(函数)