이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;
int k[100001];
priority_queue<pair<int, int>> pq;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
FOR(i, 0, n) {
cin >> k[i];
pq.push({k[i], i});
}
int ans = 0, curr = 0;
while (pq.size()) {
int h, indx;
tie(h, indx) = pq.top();
pq.pop();
if ((indx == 0 || h >= k[indx - 1]) && (indx == n - 1 || h > k[indx + 1])) curr++;
else if ((indx != 0 && h < k[indx - 1]) && (indx != n - 1 && h < k[indx + 1])) curr--;
ans = max(ans, curr);
}
cout << ans;
return 0;
}
# | 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... |