Elevator

 1 import java.util.Scanner;
 2 
 3 public class Main{
 4     public static void main(String args[]) {
 5         Scanner sc=new Scanner(System.in);
 6         while(true){
 7             int n=sc.nextInt();
 8             if(n==0) {
 9                 break;
10             }
11             int current=0;
12             int temp=0;
13             int tsum=0;
14             for(int i=0;i<n;i++) {
15                 int end=sc.nextInt();
16                 if(end>temp) {
17                     tsum=tsum+(end-temp)*6+5;
18                 }
19                 else {
20                     tsum=tsum+(temp-end)*4+5;
21                 }
22                 temp=end;
23             }
24             System.out.println(tsum);
25         }
26     }
27 }

 

posted @ 2018-05-24 16:47  f--  阅读(102)  评论(0编辑  收藏  举报