首页 > 代码库 > HDU 1008 Elevator

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;  } 

HDU 1008 Elevator