#include<iostream>
#include<vector>
using namespace std;
int main()
{
int N;
while (cin >> N)
{
int i = 1;
vector<int> Height(N + 1);
int count = 0;
for (; i < N + 1; i++)
cin >> Height[i];
i = 1;
while (i <= N)
{
if (Height[i] > Height[i + 1])
{
while (Height[i] > Height[i + 1])
{
++i;
if (i == N && (Height[i] > Height[i - 1]))
{
count++;
break;
}
if (i == N && (Height[i] < Height[i - 1]))
break;
}
count++;
}
else
++count;
++i;
}
cout << count << endl;
}
return 0;
}
京东笔试第一题,不知道能不能过全部,希望来大佬测试下!
最新推荐文章于 2024-04-24 23:01:09 发布