hdoj 1008

来源:互联网 发布:java代码生成uml类图 编辑:程序博客网 时间:2024/06/06 18:44
#include<iostream>
using namespace std;
int main(void)
{
    int up = 6, down = 4, stop = 5, total;
    while (cin >> total && total != 0)
    {
        int time = 0, cur = 0, aim = 0;
        while (total--)
        {
            cin >> aim;
            if (aim >= cur)
            {
                time += (aim - cur) * up + stop;
                cur = aim;
            }
            else
            {
                time += (cur - aim) * down + stop;
                cur = aim;
            }
        }
        cout << time << endl;
    }
    return 0;
}