This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |