HDU 1008 Elevator

题解:简单模拟

#include <cstdio>    
int main(){  
    int n,tmp,ans,now,pre;      
    while(~scanf("%d",&n)&&n){  
        ans=0; pre=0;
        for(int i=0;i<n;i++){  
            scanf("%d",&now);  
            tmp=now-pre;  
            if(tmp>0)ans+=(tmp*6+5);  
            else if(tmp<0)ans+=(-tmp*4+5);  
            else ans+=5; pre=now;   
        }printf("%d\n",ans);  
    }return 0;  
} 
posted @ 2014-08-29 15:36  forever97  阅读(132)  评论(0编辑  收藏  举报