题目描述
基本模拟。
C++ 代码
#include <iostream>
using namespace std;
const int N = 110;
int n, res, a[N];
int main()
{
cin >> n;
for (int i = 1; i <= n; i ++) cin >> a[i];
for (int i = 0; i < n; i ++)
if (a[i + 1] > a[i]) res += 6 * (a[i + 1] - a[i]);
else res += 4 * (a[i] - a[i + 1]);
res += (n * 5);
cout << res;
}