#include <stdio.h>
#define MAX 30000
int n,current=0,total=0,request;
int main(){
//freopen("/Users/pantingting/Documents/code/data/input", "r", stdin);
scanf("%d",&n);
for (int i=0; i<n; i++) {
scanf("%d",&request);
if (request>current) {
total+=(request-current)*6+5;
current=request;
}
else{
total+=(current-request)*4+5;
current=request;
}//要注意如果请求是当前层的话,也是要+5的
}
printf("%d\n",total);
return 0;
}
PAT 1008. Elevator (20)
最新推荐文章于 2018-04-10 23:35:22 发布