Submission #897201

#TimeUsernameProblemLanguageResultExecution timeMemory
897201AndrijaMGlobal Warming (NOI13_gw)C++14
0 / 40
204 ms26420 KiB
#include <bits/stdc++.h> using namespace std; const long long maxn=1e4+10; const long long mod=1e9+7; int main() { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); int n; cin>>n; vector<pair<int,int>>v; bool vis[n]; vector<int>og; for(int i=0;i<n;i++) { vis[i]=0; int h; cin>>h; v.push_back({h,i}); og.push_back(h); } int ans=1; sort(v.begin(),v.end()); for(int i=0;i<n;i++) { int j=i-1; while(j+1<n && v[j+1].first==v[i].first) { j++; if(vis[v[j].second]==true)continue; int l=v[j].second; int r=v[j].second; vis[l]=true; while(l-1>=0 && og[l-1]==v[j].first) { l--; vis[l]=true; } while(r+1<n && og[r+1]==v[j].first) { r++; vis[r]=true; } if(l-1>=0 && r+1<n) { if(vis[l-1]==0 && vis[r+1]==0) { ans++; } } ///cout<<i<<" "<<ans<<endl; } i=j; } 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...