1008 Elevator (20分)

#include <iostream>
#include <cstdio>
#include <cstring>
int main() {
    //std::cout << "Hello, World!" << std::endl;
    int n , tmp=0, floor,ans=0;
    scanf("%d",&n);
    for (int i = 0; i < n; ++i) {
        scanf("%d",&floor);
        if(floor>tmp){
            ans+=5+6*(floor-tmp);
        }else{
            ans+=5+4*(tmp-floor);
        }
        tmp=floor;
    }
    printf("%d\n",ans);
    return 0;
}
View Code

ak

posted @ 2020-10-28 21:28  ethon-wang  阅读(93)  评论(0编辑  收藏  举报