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;
#define int long long
const int maxn=1e6+10;
const int mod=1e9+7;
map<int,vector<int>>pos;
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
///freopen("prieteni.in","r",stdin);
///freopen("prieteni.out","w",stdout);
int n;
cin>>n;
int x[n];
vector<int>v;
for(int i=0;i<n;i++)
{
cin>>x[i];
v.push_back(x[i]);
pos[x[i]].push_back(i);
}
sort(v.begin(),v.end());
auto it=unique(v.begin(),v.end());
v.resize(distance(v.begin(),it));
bool vis[n];
memset(vis,0,sizeof vis);
int ans=1;
int sum=1;
for(int i=0;i<v.size();i++)
{
int koj=v[i];
for(auto idx:pos[koj])
{
if(idx==0 || idx==n-1)
{
sum--;
vis[idx]=1;
continue;
}
if(vis[idx-1]==0 && vis[idx+1]==0)
{
sum++;
vis[idx]=1;
continue;
}
if(vis[idx-1]==1 && vis[idx+1]==1)
{
sum--;
vis[idx]=1;
continue;
}
vis[idx]=1;
}
ans=max(ans,sum);
}
cout<<ans<<endl;
return 0;
}
Compilation message (stderr)
gw.cpp: In function 'int main()':
gw.cpp:36:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | for(int i=0;i<v.size();i++)
| ~^~~~~~~~~
# | 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... |