1 https://www.patest.cn/contests/pat-a-practise
2 源代码
#include<stdio.h> int main(void){ int n,i,time; time=0; scanf("%d",&n); int a[1000]; a[0]=0; for(i=1;i<=n;i++){ scanf("%d",&a[i]); if(a[i]>a[i-1]){ time+=(a[i]-a[i-1])*6; }else if(a[i-1]>a[i]){ time+=(a[i-1]-a[i])*4; } time=time+5; } printf("%d",time); }