HDU 1008 Elevator
#include<stdio.h> int main( ) { int n,sum,a,b; while( scanf( "%d",&n ),n ) { sum = 0; a = 0; for( int i = 0; i < n; ++i ) { scanf( "%d",&b ); sum += 5; if( b > a ) sum += ( b - a ) * 6; if( b < a ) sum += ( a - b ) * 4; a = b; } printf( "%d\n",sum ); } return 0; }
本人还是新手 ,转载请注明来自Lvsi‘s home