Elevator
#include<stdio.h> #include<string.h> #include<stdlib.h> int A[110],t=0; void fun(int x ) { if(x-1==-1) t+=A[x]*6+5; else if(A[x]>A[x-1]) t+=(A[x]-A[x-1])*6+5; else if(A[x]<A[x-1]) t+=(A[x-1]-A[x])*4+5; else if(A[x]==A[x-1]) t+=5; } int main( ) { int N,i; while(scanf("%d",&N),N) { memset(A,0,sizeof(A)); for(i=0;i<N;i++) scanf("%d",&A[i]); for(i=0;i<N;i++) fun(i); printf("%d\n",t); t=0; } return 0; } //刚开始时没有考虑A[i]==A[i-1]。。wa了一次。
posted on 2011-05-03 17:34 more think, more gains 阅读(171) 评论(0) 编辑 收藏 举报