Advanced 1008 Elevator
2018-12-31 本文已影响0人
zilla
#include <stdio.h>
int main() {
int curr,next,num,ans;
while (scanf("%d", &num) != EOF) {
next=0;
ans=0;
for(int i=0;i<num;i++) {
curr = next;
scanf("%d", &next);
if (next > curr) {
ans += (next - curr) * 6 + 5;
} else if (next < curr) {
ans += (curr - next) * 4 + 5;
} else {
ans += 5;
}
}
printf("%d\n",ans);
}
return 0;
}