#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
ll n; cin >> n;
vector<ll> a(n); for (auto &x: a) cin >> x;
auto f = [&](ll h) {
ll ans = 0;
bool curr = false;
for (ll i = 0; i < n; i++)
if (a[i] > h) {
if (!curr) ans++;
curr = true;
} else curr = false;
return ans;
};
ll mx = *max_element(a.begin(), a.end());
ll best = 0;
for (ll i = 0; i <= mx; i++)
best = max(best, f(i));
cout << best;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |