标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 49406 Accepted Submission(s):
27244
#include<stdio.h> int main() { int n,m,j,i,l,t,sum; int a[110]; while(scanf("%d",&n)&&n!=0) { m=0;sum=0; a[0]=0; for(i=1;i<=n;i++) { scanf("%d",&a[i]); if(a[i]>m) //上楼的情况 { sum+=(a[i]-a[i-1])*6+5; m=a[i]; } else if(a[i]<m) //下楼的情况 { sum+=(m-a[i])*4+5; m=a[i]; } else if(a[i]==m) //在相同楼层的问题 { sum+=5; m=a[i]; } } printf("%d\n",sum); } return 0; }
标签:
原文地址:http://www.cnblogs.com/tonghao/p/4376052.html