1008 Elevator (20 分)难度: 简单 / 知识点: 模拟

Posted 辉小歌

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了1008 Elevator (20 分)难度: 简单 / 知识点: 模拟相关的知识,希望对你有一定的参考价值。


https://pintia.cn/problem-sets/994805342720868352/problems/994805511923286016
直接模拟即可。

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int s[N],n,sum,L;
int main(void)
{
	cin>>n;
	for(int i=0;i<n;i++) cin>>s[i];
	for(int i=0;i<n;i++)
	{
		if(L<s[i])
		{
			sum+=(s[i]-L)*6;
			L=s[i];
		}
		else if(L>s[i])
		{
			sum+=(L-s[i])*4;
			L=s[i];
		}
	}
	cout<<sum+5*n<<endl;
	return 0;
}

以上是关于1008 Elevator (20 分)难度: 简单 / 知识点: 模拟的主要内容,如果未能解决你的问题,请参考以下文章

1008 Elevator (20分)

PAT甲级1008 Elevator (20分)

[PTA] PAT(A) 1008 Elevator (20 分)

1008 Elevator (20 分)

1008 Elevator (20分)

A1008 Elevator (20分)