杭电1008

来源:互联网 发布:潞河国际教育学园 知乎 编辑:程序博客网 时间:2024/04/29 22:54
#include<iostream>using namespace std;int main(){    int n;    while (cin >> n){        if (n == 0)break;        int a, time = n * 5, temp = 0;        while (n--) {            cin >> a;            if (a > temp) time += (a - temp) * 6;            else time += (temp - a) * 4;            temp = a;        }        cout << time << endl;    }    return 0;}

1 0