现在的位置: 首页 > 综合 > 正文

【PAT Advanced Level】1008. Elevator (20)

2018年03月22日 ⁄ 综合 ⁄ 共 219字 ⁄ 字号 评论关闭

没什么难的,简单模拟题

#include <iostream>
using namespace std;

int main()
{
	int num;
	cin>>num;
	int cost = 0;
	int curFloor = 0;
	while (num--)
	{
		int floor;
		cin>>floor;
		int tmp = floor - curFloor;
		cost += tmp > 0 ? 6 * tmp : -4 * tmp;
		cost += 5;
		curFloor = floor;
	}

	cout<<cost<<endl;
}

抱歉!评论已关闭.