1008:
电梯上升一层6秒,下降4秒,停留5秒。给出请求序列求总时间。
Sample Input:
3 2 3 1
Sample Output:
41
电梯上升一层6秒,下降4秒,停留5秒。给出请求序列求总时间。
Sample Input:
3 2 3 1
Sample Output:
41
#include<iostream>
using namespace std;
int main()
{
int curr=0;
int next;
int n;
int time=0;
cin>>n;
while(n--)
{
cin>>next;
if(next>curr)
time+=(next-curr)*6;
else if(next<curr)
time+=(curr-next)*4;
time+=5;
curr = next;
}
cout<<time;
}