#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
int main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll n;
cin >> n;
vector<pll> heights(n);
for (ll i = 0; i < n; i++)
{
cin >> heights[i].first;
heights[i].second = i;
}
sort(heights.begin(), heights.end(), greater<pll>());
vector<bool> used(n, false);
ll ans = 0, curr = 0;
for (ll i = 0; i < n; i++)
{
ll ind = heights[i].second;
used[ind] = true;
if (i < n - 1 && heights[i].first == heights[i + 1].first) continue;
if ((ind == 0 || (!used[ind - 1])) && (ind == n - 1 || (!used[ind + 1])))
curr++;
if (ind && ind < n - 1 && used[ind - 1] && used[ind + 1])
curr--;
ans = max(ans, curr);
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
15 ms |
2144 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
19 ms |
2660 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
255 ms |
25444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
216 ms |
24680 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |