杭电1008题

#include <iostream>
using namespace std;


int main()
{
	int iStopCount;
	int iStopTimePerFloor = 5;
	int iMoveUpTimePerFloor = 6;
	int iMoveDownTimePerFloor = 4;
	int iCurrentStopFloor;
	int iSumTime;
	while(cin >> iStopCount)
	{
		if(0 == iStopCount)
		{
			return 0;
		}
		else
		{
			int iStopTime = iStopTimePerFloor * iStopCount;
			int iMoveTime = 0;
			int lastFloor = 0;
			for(int i = 0; i < iStopCount; i++)
			{
					cin >> iCurrentStopFloor;
					iMoveTime += (iCurrentStopFloor > lastFloor ? 
					          iMoveUpTimePerFloor * (iCurrentStopFloor - lastFloor): 
					          iMoveDownTimePerFloor * (lastFloor - iCurrentStopFloor));
					lastFloor = iCurrentStopFloor;
			}
			iSumTime = iMoveTime + iStopTime;
			cout << iSumTime << endl;
		}
	}
	
	return 0;
}


题目:点击打开链接

你可能感兴趣的:(杭电1008题)