QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#736438#8040. Let Them Eat Cakewhp2602765865WA 0ms3620kbC++17630b2024-11-12 11:05:162024-11-12 11:05:18

Judging History

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

  • [2024-11-12 11:05:18]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3620kb
  • [2024-11-12 11:05:16]
  • 提交

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 maxx = 0;
		int m = a.size();
		for (int i = 0; i < m; i++)
		{
			if (i == 0)
				maxx = max(maxx, a[i + 1]);
			else if (i == m - 1)
				maxx = max(maxx, a[i - 1]);
			else
				maxx = max(maxx, min(a[i - 1], a[i + 1]));
		}
		vector<int>b;
		for (int i = 0; i < m; i++)
			if (a[i] > maxx)b.push_back(a[i]);
		a = b;
		ans++;
	}
	cout << ans;
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3620kb

input:

5
1 2 3 4 5

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3608kb

input:

5
1 5 3 4 2

output:

1

result:

wrong answer 1st numbers differ - expected: '2', found: '1'