HDU 1008 Elevator

 

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1008

纯水题,就是要注意即使下一站是同一楼层也要停5秒

贴上代码:
 1 #include <iostream>
 2 #include <vector>
 3 using namespace std;
 4 
 5 int main (){
 6     int n , time, i;
 7     while ( cin >> n )
 8     {
 9         if ( n==0 )
10             break;
11         vector<int>floor(n);
12         time=0;
13         cin>>floor[0];
14         time+=floor[0]*6+5;
15 
16         for (i=1; i<n; i++ )
17         {
18             cin>>floor[i];
19             if ( floor[i]<floor[i-1] )
20                 time+= floor[i-1]*4-floor[i]*4 + 5;              //down
21             else if ( floor[i] >= floor[i-1] )  
22                 time+= floor[i]*6-floor[i-1]*6 + 5;              //up
23         }
24         cout<<time<<endl;
25     }
26     return 0;
27 }

 

 
posted @ 2013-12-14 16:47  neverchanje  阅读(137)  评论(0)    收藏  举报