Submission #993458

#TimeUsernameProblemLanguageResultExecution timeMemory
993458AndrijaMGlobal Warming (NOI13_gw)C++14
0 / 40
174 ms16980 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int maxn=1e6+10; const int mod=1e9+7; struct st { int val; int idx; }v[maxn]; bool vis[maxn]; bool S(st x,st y) { return x.val<y.val; } signed main() { ios::sync_with_stdio(false); cin.tie(0); ///freopen("prieteni.in","r",stdin); ///freopen("prieteni.out","w",stdout); int n; cin>>n; for(int i=1;i<=n;i++) { cin>>v[i].val; v[i].idx=i; } sort(v+1,v+n+1,S); int ans=1; int sum=1; int i=1; while(i<=n) { int j=i-1; while(j+1<=n && v[j+1].val==v[i].val) { j++; } for(;i<=j;i++) { int ind=v[i].idx; if(vis[ind-1]==1 && vis[ind+1]==1) { sum--; } if(!vis[ind-1] && !vis[ind+1]) { sum++; } vis[ind]=1; } ans=max(ans,sum); } cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...