Radio Towers
문제
There are radio towers in Jakarta. The towers are located along a straight line and numbered from to from left to right. For each such that , the height of tower is metres. The heights of the towers are distinct.
For some positive interference value , a pair of towers and (where ) can communicate with each other if and only if there is an intermediary tower , such that
- tower is to the left of tower and tower is to the right of tower , that is, , and
- the heights of tower and tower are both at most metres.
Pak Dengklek wants to lease some radio towers for his new radio network. Your task is to answer questions of Pak Dengklek which are of the following form: given parameters and ( and ), what is the maximum number of towers Pak Dengklek can lease, assuming that
- Pak Dengklek can only lease towers with indices between and (inclusive), and
- the interference value is , and
- any pair of radio towers that Pak Dengklek leases must be able to communicate with each other.
Note that two leased towers may communicate using an intermediary tower , regardless of whether tower is leased or not.