解题报告:hdu1008 Elvator

2017-09-07 19:30:22

writer:pprp

比较顺利,最近生活出现了各种问题,

发生了很多矛盾,我要耐下心来,最重要的不是努力不努力,而是选择

希望我能处理好人际关系还有学业上的压力。

/*
@theme: hdu1008 Elevator
@writer:pprp
@begin:21:37
@end:19:30
@declare:水题
@data:2017/9/7
*/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    //freopen("in.txt","r",stdin);
    int n;
    while(cin >> n && n)
    {
        int before = 0,now = 0;
        int ans = 0;

        for(int i = 0; i < n ; i++)
        {
            cin >> now;
            if(now > before)
            {
                ans += 6 * (now - before);
            }
            else
            {
                ans += 4 * (before - now);
            }
            before = now;
        }
        ans += 5 * n;
        cout << ans << endl;
    }
    return 0;
}
原文地址:https://www.cnblogs.com/pprp/p/7491480.html