QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#736455#8040. Let Them Eat Cakewhp2602765865TL 0ms0kbC++17568b2024-11-12 11:12:082024-11-12 11:12:13

Judging History

你现在查看的是最新测评结果

  • [2024-11-12 11:12:13]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-11-12 11:12:08]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int ans = 0;
	while (a.size() > 1)
	{
		int m = a.size();
		vector<bool>v(m);
		for (int i = 0; i < m; i++)
		{
			if (i != 0 && a[i] < a[i + 1])
				v[i] = 1;
			if (i != m - 1 && a[i] < a[i - 1])
				v[i] = 1;
		}
		vector<int>b;
		for (int i = 0; i < m; i++)
			if (!v[i])b.push_back(a[i]);
		a = b;
		ans++;
	}
	cout << ans;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

5
1 2 3 4 5

output:


result: