import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.StreamTokenizer; public class Main { @SuppressWarnings("unchecked") public static void main(String[] args) throws IOException { StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); in.nextToken(); int n = (int) in.nval; int last = 0; int sum = 0; for (int i = 0; i < n; i++) { in.nextToken(); int next = (int) in.nval; if (next > last) { sum += 6 * (next - last); sum += 5; last = next; } else { sum += 4*(last - next); sum += 5; last = next; } } System.out.println(sum); } }
标签:PAT,java,int,sum,Elevator,next,io,1008,last From: https://www.cnblogs.com/fishcanfly/p/17783347.html