#include <bits/stdc++.h>
using namespace std;
#define int long long
int h[100010];
signed main()
{int n;
while(scanf("%lld",&n)==1)
{
if(n==0) break;
for(int i=1;i<=n;i++) scanf("%lld",&h[i]);
int time=0;
h[0]=0;
for(int i=1;i<=n;i++)
{
if(h[i]>h[i-1]) time += (h[i]-h[i-1])*6+5;
else if(h[i]<h[i-1]) time += (h[i-1]-h[i])*4+5;
}
cout<<time<<endl;
}
}
你站在某大厦的第 0 层的一个电梯门口前,手里拿着一份任务表,表里记录着 n 个整数 h 1 ,h 2,...,hn,代表你需要先坐电梯到第 h 1 层(到后停留5秒),再到第 h 2层(到后停留5秒),… , 最后到达 第 hn层(到后停留5秒)。 请问:完成这个任务需要多少秒?( 已知电梯上升一层花费6秒,下降一层花费4秒,到达目标层后停留5秒)
多组数据输入 1<=n,h<=100 大家都应该知道这是一道大水题,但问题是为啥我过不去?