Smile9870

1008. Elevator (20)

生词(在文中意思)

denote 代表

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int pos = 0, sum = 0;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            if (a > pos) {
                sum += (a - pos) * 6;
                pos = a;
            }
            if (a < pos) {
                sum += (pos - a) * 4;
                pos = a;
            }
            sum += 5;
        }
        System.out.print(sum);
    }

}

 

posted on 2018-01-03 17:35  Smile9870  阅读(100)  评论(0编辑  收藏  举报

导航