玄关
查看原帖
玄关
1247040
V_HAPPY666楼主2024/5/25 20:10

此题不符合生活常识

电梯门只开不关的吗(?

AC代码

//此程序完全按照题面意思完成,为顺序结构
#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n,ans=0,last=0;
	cin >> n;
	int s[n];
	for (int i = 0; i < n ; i++)
	{
		cin >> s[i];
	}
	sort(s, s + n);
	int high=s[n-1];
	int cnt = unique(s, s + n) - s;
	for(int i=0;i<cnt;i++)
	{
		ans+=((s[i]-last)*6+5+1);
		last=s[i];
	}
	ans+=(n-cnt)*1;
	ans+=high*4;
	cout<<ans;
	return 0;
}

2024/5/25 20:10
加载中...