1008. Elevator

// 1008. Elevator.cpp: 主項目文件。

#include "stdafx.h"
#include <cstdio>

int main()
{
    int n;
	scanf("%d",&n);
	int sum=sum=5*n,pre=0;
	for(int i=0;i<n;i++){
		int temp;
		scanf("%d",&temp);
		if(temp>pre)
			sum+=6*(temp-pre);
		else
			sum+=4*(pre-temp);
		pre=temp;
	}
	printf("%d\n",sum);
    return 0;
}



發佈了145 篇原創文章 · 獲贊 3 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章