Submission #960910

#TimeUsernameProblemLanguageResultExecution timeMemory
960910AlgorithmWarriorGlobal Warming (NOI13_gw)C++14
40 / 40
379 ms18572 KiB
#include <bits/stdc++.h> #define MAX 1000005 using namespace std; struct str { int val; int ind; }v[MAX]; bool sol[MAX]; bool crt(str a,str b) { return a.val<b.val; } int main() { int n; cin>>n; int i; for(i=1;i<=n;++i) { cin>>v[i].val; v[i].ind=i; sol[i]=1; } sort(v+1,v+n+1,crt); int maxim=1; int act=1; for(i=1;i<=n;) { int j=i; while(j<n && v[j].val==v[j+1].val) ++j; for(;i<=j;++i) { int ind=v[i].ind; if(sol[ind-1] && sol[ind+1]) ++act; if(!sol[ind-1] && !sol[ind+1]) --act; sol[ind]=0; } maxim=max(maxim,act); } cout<<maxim; 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...