原题
http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=1§ionid=2&problemid=1
源码
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while(in.hasNext()) {
int n, from = 0, to, t = 0;
n = in.nextInt();
for (int i = 0; i < n; i++) {
to = in.nextInt();
if (to > from) {
t += (to - from) * 6;
} else
t += (from - to) * 4;
from = to;
t += 5;
}
if(n != 0)
System.out.println(t);
}
}
}