1008 Elevator (20)

来源:互联网 发布:网络直播的定义 编辑:程序博客网 时间:2024/04/29 01:16
#include<iostream>using namespace std;int main(){    int total;    int N;    cin>>N;    total=N*5;    int e_before=0;    int e_now;    for(int t=0;t<N;t++)    {        cin>>e_now;        if(e_now>e_before)        {            total+=6*(e_now-e_before);        }        else        {            total+=4*(e_before-e_now);        }        e_before=e_now;    }    cout<<total<<endl;}
0 0