# Elevator

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 50645    Accepted Submission(s): 27932

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
```

Author

ZHENG, Jianqiang

Source

ZJCPC2004

Recommend

JGShining   |   We have carefully selected several similar problems for you:  1009 1021 1003 1108 1019

3  2  3  1

41

```import java.io.*;
import java.util.*;

public class Main
{

public static void main(String[] args)
{
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
while(input.hasNext())
{
int n = input.nextInt();
if(n==0)
break;
int begin=0,stop=0,sum=0;                //begin表示前面电梯所在的楼层，stop表示电梯要达到的楼层
for(int i=0;i<n;i++)
{
stop = input.nextInt();
if(stop>begin)
{
sum+=(stop-begin)*6+5;
}
else
{
sum+=(begin-stop)*4+5;
}
begin = stop;
}
System.out.println(sum);
}
}
}
```

## 1419: 电梯来了

Time Limit: 1 Sec  Memory Limit: 128 MB

Submit: 176  Solved: 123

[Submit][Status][Web
Board
]

## Sample Input

1 23 2 3 15 1 5 4 3 10

174171

## Source

[Submit][Status][Web
Board
]

## hdu 1008 elevator

#include<iostream> #include<stdio.h> #include<math.h> #include<algorithm> using namespace std; int main() { int n; while(~scanf("%d",&n)&&n!=0) { int a,b; a=0; int ans=0; for(int i=0;i<n;i++) { scanf("

## HDU 5059 Help him（简单模拟题）

http://acm.hdu.edu.cn/showproblem.php?pid=5059 题目大意: 给定一个字符串,如果这个字符串是一个整数,并且这个整数在[a,b]的范围之内(包括a,b),那就输出YES,其它的都是NO. 这个字符串是整数的条件: 1.如果它是正整数,它只包含前导不是0的数(这个数前面没有零). 2.如果它是负整数,只包含一个'-'符号,任然没有前导0. 3.除此之外都不是非法的 解题思路: http://bestcoder.hdu.edu.cn/ 这里有 要注意: 0

## HDU 4891 简单模拟

The Great Pan Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1035    Accepted Submission(s): 355 Problem Description As a programming contest addict, Waybl is always happy to take part in vario