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 <bits/stdc++.h>
#include "towers.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
vi v;
int n;
void init(int N, vi h) {
v=h;
n=N;
}
int max_towers(int l, int r, int d) {
int ans=1;
int v1=-1;
int p1=-1;
bool ban=false;
for(int i=l+1; i<=r; i++){
// cout<<v1<<" "<<p1<<" "<<v[i-1]<<endl;
if(v[i]<v[i-1]){
if(p1!=-1){
if(p1-v1<=d){
p1=-1;
v1=-1;
}else{
ban=true;
}
}
}
if(v[i]>v[i-1] || i==r){
if(i==r) i++;
if(ban==true){
if(p1-v[i-1]>=d){ ans++; /*cout<<v1<<" "<<p1<<" "<<v[i-1]<<endl;*/}
ban=false;
}
if(v1==-1){
v1=v[i-1];
}
p1=v[i];
}
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |