简单模拟。
#include<cstdio>
using namespace std;
int main(void) {
// freopen("in.txt","r",stdin);
int N;
scanf("%d",&N);
int last=0,curr;
long long ans=0;
while(N--){
scanf("%d",&curr);
if(curr>last) ans+=6*(curr-last);
else if(curr<last) ans+=4*(last-curr);
ans+=5;
last=curr;
}
printf("%lld\n",ans);
return 0;
}
/*
Sample Input:
3 2 3 1
Sample Output:
41
*/
网友评论