# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
628867 | kkkkkkkk | Radio Towers (IOI22_towers) | C++17 | 0 ms | 0 KiB |
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>
using namespace std;
vector<int> height;
int N,k=0;
void init(int n,vector<int> H)
{
N=n;
height=H;
}
int max_towers(int l,int r,int d)
{
int res=1;
vector<int> dp(n,1);
for (int i=l;i<=r;i++)
{
int tower=height[i-1];
for (int j=i-2;j>=l;j--)
{
if (tower-d>=height[j]&&tower-d>=height[i])
dp[i]=max(dp[i],dp[j]+1);
tower=max(tower,height[j]);
}
res=max(dp[i],res);
}
return res;
}