读懂题意,英文理解即可,一道模拟题
#include<bits/stdc++.h>
using namespace std;
//The numbers denote at which floors the elevator will stop, in specified order.
//数字代表的每一层电梯都会按照指定的顺序停靠
const int MAXN = 110;
int a[MAXN];
int main(void)
{
freopen("pat0314/in.txt","r",stdin);
int n;
cin>>n;
for(int i = 0;i<n;i++)
{
cin>>a[i];
}
int res = 0;
for(int i = 0;i<n;i++)
{
if(i == 0)
{
res += (a[i] * 6) + 5;
}
else if(a[i] > a[i - 1])
{
res += (a[i] - a[i - 1]) * 6 + 5;
}
else
{
res += (a[i - 1] - a[i]) * 4 + 5;
}
}
printf("%d",res);
return 0;
}