zju-pat 1008.Elevator

#include<iostream>
#include<algorithm>
using namespace std;

int n;
int a[105];

void run()
{
	int i;
	
	for(i=0;i<n;i++) scanf("%d",&a[i]);

	int ans=0;
	int cur=0;

	for(i=0;i<n;i++) 
	{
		if(a[i]>cur)
		{
			ans=ans+(a[i]-cur)*6;
			ans+=5;
			cur=a[i];
		}
		else if(a[i]<cur)
		{
			ans=ans+(cur-a[i])*4;
			ans+=5;
			cur=a[i];
		}
		else ans+=5;
	}

	printf("%d\n",ans);
}

int main()
{
	while(scanf("%d",&n)!=EOF) run();
	return 0;
}
注意同一层下加上时间5S

你可能感兴趣的:(zju-pat 1008.Elevator)