QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#736455 | #8040. Let Them Eat Cake | whp2602765865 | TL | 0ms | 0kb | C++17 | 568b | 2024-11-12 11:12:08 | 2024-11-12 11:12:13 |
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;
}
詳細信息
Test #1:
score: 0
Time Limit Exceeded
input:
5 1 2 3 4 5