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 <vector>
#include<bits/stdc++.h>
using namespace std;
using ll = int;
ll n;
vector<ll> h;
void init(int N, std::vector<int> H) {
n = N;
h = H;
}
int max_towers(int L, int R, int D) {
vector<ll> dp(R-L+1,1);
for(ll i = L+2;i<=R;i++){
ll mx = 0;
for(ll j = i-1;j>=L;j--){
if (mx>=max(h[i],h[j])){
dp[i-L] = max(dp[i-L],dp[j-L]+1);
}
mx = max(mx,h[j]-D);
}
}
ll ans = 0;
for(ll i : dp) ans = max(i,ans);
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... |