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 "towers.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n;
int h[maxn];
void init(int _n, vector<int> _h) {
n=_n;
for(int i=0;i<n;i++) h[i]=_h[i];
}
int resi(int l,int r,int d,int naj=1e9+10){
if(r<l) return 0;
pair<int,int> maxi={-1,-1};
int klk=0;
for(int i=l;i<=r;i++){
if(h[i]<=naj) klk++;
maxi=max(maxi,{h[i],i});
}
return max(resi(l,maxi.second-1,d,maxi.first-d)+resi(maxi.second+1,r,d,maxi.first-d),int(klk>0));
}
int max_towers(int l, int r, int d) {
return resi(l,r,d);
}
# | 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... |