Submission #751919

#TimeUsernameProblemLanguageResultExecution timeMemory
751919AndiRGlobal Warming (NOI13_gw)C++14
6 / 40
453 ms18744 KiB
#include <iostream> #include <algorithm> using namespace std; const int Nmax=1000000; struct island{ int h, t; }e[Nmax*2+5]; int n, v[Nmax+1]; bool cmp(island a, island b){ return a.h<b.h; } int main() { cin>>n; for (int i=0; i<n; i++) cin>>v[i]; int mx=0, nris=0; for (int i=0; i<n; i++){ if (mx<v[i]) mx=v[i]; if (v[i]<v[i-1] && v[i]<v[i+1]){ e[nris*2].t=1; e[nris*2].h=v[i]; e[nris*2+1].t=-1; e[nris*2+1].h=mx; mx=0; nris++; } } e[nris*2].t=-1; e[nris*2].h=mx; sort(e, e+nris*2+1, cmp); int crt=1, i=0; mx=1; while(i<=nris*2){ while (e[i].h==e[i+1].h){ crt+=e[i].t; i++; } crt+=e[i].t; if (crt>mx) mx=crt; i++; } cout<<mx; 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...