Transmitter Towers
Time limit2sMemory limit1024 MB
For each query range [L, R] and value D, find the largest set of towers where every pair has a relay tower between them that is at least D taller.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Greedy, Sorting
- Solved
- No attempts yet
Problem
Jakarta has transmitter towers. The towers lie on a straight line and are numbered from to from left to right. For each with , the height of tower is meters. All tower heights are distinct.
For a positive interference value , towers and () can communicate if there is a relay tower that satisfies both of the following conditions.
- . That is, tower is to the left of tower , and tower is to the right of it.
- The heights of towers and are each at most meters.
Pak Dengklek wants to rent some towers for her new transmission network. You must answer queries. Each query gives parameters , , and (, ), and asks for the maximum number of towers Pak Dengklek can rent. Assume the following:
- She may rent only towers numbered from to , inclusive.
- The interference value is .
- Every pair of towers she rents must be able to communicate.
When two rented towers communicate through a relay tower , tower may or may not be rented.
Constraints
- (for all )
- (for all )