#include<bits/stdc++.h>
using namespace std;
const int mx=1e6+200;
typedef long long ll;
int inf=1e9+10;
const int mod=1e9+7;
ll n,m,k;
vector<pair<ll,ll>>v;
vector<pair<ll,ll>>adj[mx];
ll best[mx];
ll vis[mx];
ll ans=0;
ll a[mx];
int main(){
cin>>n;
a[0]=-1;
a[n+1]=-1;
for(int i=1;i<=n;i++){
cin>>a[i];
v.push_back({a[i],i});
}
sort(v.rbegin(),v.rend());
ll cur=0;
ll ans=0;
map<int,int>mp;
for(ll i=0;i<n;i++){
cur++;
ll me=v[i].second;
vis[me]=1;
if((vis[me+1])){
cur--;
} if(vis[me-1]){
cur--;
}
if(i==n-1||a[me+1]!=a[me]){
ans=max(ans,cur);
}
// cout<<cur;
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
23756 KB |
Output is correct |
2 |
Correct |
15 ms |
23756 KB |
Output is correct |
3 |
Correct |
15 ms |
23756 KB |
Output is correct |
4 |
Correct |
14 ms |
23840 KB |
Output is correct |
5 |
Correct |
15 ms |
23836 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
47 ms |
27024 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
65 ms |
27016 KB |
Output is correct |
2 |
Correct |
52 ms |
26984 KB |
Output is correct |
3 |
Correct |
67 ms |
26956 KB |
Output is correct |
4 |
Correct |
65 ms |
27004 KB |
Output is correct |
5 |
Correct |
64 ms |
26936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
609 ms |
55180 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
584 ms |
55196 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |