PAT1008. Elevator (20)

题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1008

水题,不多说,代码如下:

#include<map>
#include<string>
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
using namespace std;

int main()
{
	//freopen("D://test.txt","r",stdin);
	int n,total=0;
	cin>>n;
	int rq[10000];
	rq[0]=0;
	for(int i=1;i<=n;i++)
	{
		cin>>rq[i];
		if(rq[i]>rq[i-1])
			total=total+(rq[i]-rq[i-1])*6;
		else if(rq[i]<rq[i-1])
			total=total+(rq[i-1]-rq[i])*4;
	}
	total=total+n*5;
	cout<<total<<endl;
	return 0;
}


你可能感兴趣的:(编程,ACM,pat,浙大)