版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Dragon_fxl/article/details/55113282
#include <stdio.h>
int main(void) {
int T, location, floor, second;
while(scanf("%d", &T), T) {
location = 0;
second = 5 * T;
while(T--) {
scanf("%d", &floor);
second += location < floor ? (floor - location) * 6 : (location - floor) * 4;
location = floor;
}
printf("%d\n", second);
}
return 0;
}