Submission #89556

#TimeUsernameProblemLanguageResultExecution timeMemory
89556sjhuang26Global Warming (NOI13_gw)C++14
19 / 40
621 ms33792 KiB
#include<iostream> #include<algorithm> using namespace std; typedef pair<int,int>ii; int N,a[1000000],ch=0,ans=-1; ii b[1000000]; //0=land,1=no land bool f[1000000]={}; int main(){ cin>>N; for(int i=0;i<N;++i){ cin>>a[i]; b[i]={a[i],i}; } sort(b,b+N); if(b[0].first>0)ans=1; for(int i=0;i<N;++i){ int x=b[i].second; if(x!=0)ch+=(f[x]==f[x-1]?1:-1); if(x!=N-1)ch+=(f[x]==f[x+1]?1:-1); f[x]=1; if((i==N-1)||(b[i].first!=b[i+1].first)){ int isl; if(f[0]){ //011223344... isl=ch/2+ch%2; }else{ //112233445... isl=ch/2+1; } ans=max(ans,isl); } } cout<<ans<<'\n';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...