水题,杭电oj 1008,帮忙看一下,总是wrong answer。

2024-12-14 23:41:41
推荐回答(1个)
回答1:

#include
using namespace std;
int main()
{
int n,i,time;
while(cin>>n,n)
{
time=0;
int *h=new int [n];
cin>>h[0];
time+=h[0]*6+5;
for(i=1;i {
cin>>h[i];
if(h[i]>h[i-1])
time+=(h[i]-h[i-1])*6+5;
else if(h[i] time+=(h[i-1]-h[i])*4+5;
else //同一层也要加5
time+=5;
}
cout< delete [] h;
}
return 0;
}