Submission #339233

#TimeUsernameProblemLanguageResultExecution timeMemory
339233Ahmad_HasanGlobal Warming (NOI13_gw)C++17
40 / 40
527 ms21768 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; vector<pair<int,int> >vps(n); for(int i=0;i<n;i++){ cin>>vps[i].first; vps[i].second=i; } sort(vps.begin(),vps.end()); int vis[n]={0}; int mx=1; int cr=0; for(int i=n-1;i>=0;i--){ vis[vps[i].second]=1; if((vps[i].second-1>=0&&vis[vps[i].second-1])&&(vps[i].second+1<n&&vis[vps[i].second+1])) cr--; else if((vps[i].second-1<0||!vis[vps[i].second-1])&&(vps[i].second+1>=n||!vis[vps[i].second+1])) cr++; if(i==0||vps[i-1].first!=vps[i].first) mx=max(mx,cr); } cout<<mx<<'\n'; return 0; } /**** 1 8 4 3 1 4 3 1 8 8 7 1 100 9 1 100 2 1 3 2 4 3 5 4 100 99 99 98 98 97 97 96 19 3 6 3 12 9 2000000000 1000000000 1000000000 3 1000000000 1000000000 */
#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...