​HDU-1008​​​
很基础的一道题只要分清步骤就好
AC的程序:

#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
//输入第一个是多少数据
int temp,a,ans,n;
while(scanf("%d",&n)&&n)
{
temp=0;
ans=0;
//计算时间
while(n--){
scanf("%d",&a);
if(a>temp)
{
ans+=6*(a-temp)+5;
}
else if(a==temp)// 不知道哪里来的习惯,总是一不小心等于就写成=。
{
ans+=5;
}
else if(a<temp)
{
ans+=4*(temp-a)+5;
}
temp=a;
}
printf("%d\n",ans);
}
return 0;
}