# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1076885 | 2024-08-26T17:58:11 Z | Trumling | Radio Towers (IOI22_towers) | C++17 | 0 ms | 0 KB |
#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; }