Submission #411654

#TimeUsernameProblemLanguageResultExecution timeMemory
411654nxteruMountains (IOI17_mountains)C++14
20 / 100
1 ms332 KiB
#include "mountains.h" #include <bits/stdc++.h> using namespace std; int maximum_deevs(vector<int> y) { int n=y.size(); if(n==1)return 1; vector<int>x; for(int i=0;i<n;i++){ if(i==0){ if(y[i]>=y[i+1])x.push_back(-1); else x.push_back(1); }else if(i==n-1){ if(y[i-1]>=y[i])x.push_back(-1); else x.push_back(1); }else{ if(y[i+1]-y[i-1]>=2*(y[i]-y[i-1]))x.push_back(-1); else x.push_back(1); } } int ans=0,p=0; for(int i=0;i<n;i++){ if(x[i]==1){ if(p==1)p=0; else{ if(p==-1)p=0; else if(i==n-1||x[i+1]!=-1){ ans++; p=1; } } }else{ if(p!=-1)ans++; p=-1; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...