该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
import java.util.Scanner;public class elevator
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
int a[][] = new int[1000][1000];
int m = 0;
int c[] = new int[1000];
int n = in.nextInt();
c[1]= n;
while (n != 0)
{
if (n != 0)
{
m = m + 1;
a[m][0] = 0;
for (int i = 1; i <= n; i++)
a[m][i] = in.nextInt();
}
n = in.nextInt();
c[m + 1] = n;
}
int b[] = new int[1000];
for (int i = 1; i <= m; i++)
{
for (int j = 1; j <= c[i]; j++)
{
if (a[i][j] - a[i][j - 1] >= 0)
b[i] = b[i] + (a[i][j] - a[i][j - 1]) * 6 + 5;
if (a[i][j] - a[i][j - 1] <= 0)
b[i] = b[i] + (a[i][j - 1] - a[i][j]) * 4 + 5;
}
}
for (int i = 1; i <= 1000; i++)
{
if (b[i] != 0)
System.out.println(b[i]);
else
break;
}
}
}