# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1036944 | 2024-07-27T20:21:49 Z | XJP12 | Radio Towers (IOI22_towers) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> #include "towers.h" using namespace std; typedef long long ll; typedef vector<int> vi; vi v; void init(int n, vi h) { v=h; } int max_towers(int l, int r, int d) { int ans=0; int v1=-1; int p1=-1; bool ban=false; for(int i=1; i<n; i++){ if(v[i]<v[i-1]){ if(p!=-1){ if(p1-v1>d){ p1=v1=-1; }else{ ban=true; } } } if(v[i]>v[i-1]){ if(ban==true){ ans++; ban=false; v1=v[i-1]; } if(v1==-1){ v1=v[i-1]; } p1=v[i]; } } return ans; }