# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1076885 | Trumling | 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 "towers.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define all(x) x.begin(),x.end()
typedef long long ll;
#define pb push_back
#define INF 9999999999999999
ll n;
vector<ll>h;
void init(int N, vector<int> H)
{
n=N;
for(int i=0;i<N;i++)
h.pb(H[i]);
}
int max_towers(int L, int R, int D)
{
vector<ll>v(n);
for(int i=L;i<=R;i++)
v[i]=1;
for(int i=L;i<=R;i++)
{
ll maxi=h[i];
for(int j=i-1;j>=L;j--)
{
maxi=max(maxi,h[j]);
if(maxi-D>=h[j] && maxi-D>=h[i])
if(v[i]<v[j]+1)
v[i]=v[j] + 1
}
}
ll maxi=0;
for(int i=0;i<n;i++)
maxi=max(maxi,v[i]);
return maxi;
}