chenxi16

导航

PATA -1008 Elevator

#include<stdio.h>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    int b,nowb,subb,res=0;
    b=0;
    for(int i=0;i<n;i++){
        scanf("%d",&nowb);
        subb = nowb - b;
        if(subb>0)  res += subb*6 + 5;
        else res += (-subb)* 4 + 5;
        b = nowb;
    }
    printf("%d",res);
    return 0;
}
View Code

 

posted on 2020-06-29 23:31  chenxi16  阅读(79)  评论(0编辑  收藏  举报