一开始想的时候吧那个搞错了,那个在同一层的时候对停留5S
1 #include2 #include 3 4 int a[3005]; 5 6 int main() 7 { 8 int n; 9 while(scanf("%d",&n) && n)10 {11 int i;12 long sum = 0;13 memset(a,0,sizeof(a));14 for(i = 1; i <= n; i++)15 scanf("%d",&a[i]);16 for(i = 1; i <= n; i++)17 {18 if(a[i] > a[i-1])19 sum += 6* (a[i] - a[i-1])+5;20 if(a[i] < a[i-1])21 sum += 4* (a[i-1] - a[i]) +5;22 if(a[i] == a[i-1])23 sum += 5;24 }25 printf("%ld\n",sum);26 }27 28 return 0;29 }