//
// main.cpp
// PAT_1008. Elevator
//
// Created by wjq on 17/3/30.
// Copyright © 2017年 wjq. All rights reserved.
//
#include <iostream>
using namespacestd;
int main(int argc,const char * argv[])
{
int N=0,time=0,current_floor=0,target_floor=0;
cin>>N;
for(int i=0;i<N;i++)
{
cin>>target_floor;
if(target_floor>current_floor)
{
time+=(target_floor-current_floor)*6+5;
current_floor=target_floor;
}
else if(target_floor<current_floor)
{
time+=(current_floor-target_floor)*4+5;
current_floor=target_floor;
}
else
time+=5;
}
cout<<time;
return 0;
}
简单题,错了一次,题意中没有说明是否可以出现 4 2 3 1 1这样的数据.
举个例子,一般人不会在电梯3层再按3,即使按了3,也不可能停留5分钟对吧.(然并卵,这题就是这样坑滴)
有点不符合常识..