HDOJ1008 Elevator
HDOJ1008 Elevator
Wrong Answer.
代码如下:
1 #include<iostream> 2 3 using namespace std; 4 5 6 int main() 7 { 8 int n; 9 while(cin>>n &&n) 10 { 11 int *a = new int[n]; 12 int sumRun=0,sumStop=0,sumTotal=0; 13 int i=0; 14 a[0]=0; 15 for (i=1;i<=n;i++) 16 { 17 cin>>a[i]; 18 if (a[i]>a[i-1]) { 19 sumRun = sumRun + ((a[i]-a[i-1])*6); 20 } 21 else if (a[i]<a[i-1]){ 22 sumRun = sumRun + ((a[i-1]-a[i])*4); 23 } 24 else{ 25 sumRun = sumRun + 0; 26 } 27 } 28 sumStop = n*5; 29 sumTotal = sumRun + sumStop; 30 cout<<sumTotal<<endl; 31 } 32 return 0; 33 }