This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int exis[1000005];
pair<int, int>arr[1000005];
int main(){
ios::sync_with_stdio(0);cin.tie(0);
int n;
cin >> n;
int ans = 0;
for(int i=1;i<=n;i++){
cin >> arr[i].first;
arr[i].second = i;
}
sort(arr+1, arr + n + 1);
int cnt = 0;
for(int i=n;i>=1;i--){
int cur = arr[i].second;
exis[cur] = true;
if(exis[cur-1] == true && exis[cur+1] == true)cnt--;
else if(exis[cur-1] == false && exis[cur+1] == false)cnt++;
if(i == 1 || arr[i].first != arr[i-1].first)ans = max(ans,cnt);
}
cout << ans;
}
# | 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... |