1008 Elevator (20point(s))

作者: iphelf | 来源:发表于2020-02-28 00:28 被阅读0次

    简单模拟。

    #include<cstdio>
    using namespace std;
    
    int main(void) {
    //    freopen("in.txt","r",stdin);
        int N;
        scanf("%d",&N);
        int last=0,curr;
        long long ans=0;
        while(N--){
            scanf("%d",&curr);
            if(curr>last) ans+=6*(curr-last);
            else if(curr<last) ans+=4*(last-curr);
            ans+=5;
            last=curr;
        }
        printf("%lld\n",ans);
        return 0;
    }
    
    /*
    Sample Input:
    3 2 3 1
    
    Sample Output:
    41
    */
    

    相关文章

      网友评论

        本文标题:1008 Elevator (20point(s))

        本文链接:https://www.haomeiwen.com/subject/ovpqhhtx.html