WiFi Range Coverage
Medium
array
range-coverage
interval-checking
geometry
Problem Description
Given house positions on a line and WiFi routers with their ranges, check if every house gets WiFi coverage. Return "YES" if all houses are covered, "NO" otherwise.
Input Format
First line: n m (houses, routers). Second line: n house positions. Third line: m router positions. Fourth line: m router ranges.
Output Format
"YES" if all houses are covered, "NO" otherwise.
Constraints
• 1 ≤ n, m ≤ 1000
• 0 ≤ positions ≤ 10^6
• 1 ≤ router ranges ≤ 10^6
• House covered if within range of any router
• Range is inclusive on both sides
Sample Input/Output
Input:
3 2 1 5 9 3 7 3 2
Output:
YES
Explanation
Houses at [1,5,9]. Routers at [3,7] with ranges [3,2]. Router 1 covers [0,6], Router 2 covers [5,9]. All houses covered.
Solution Hints
85
Points
Points
2000ms
Time Limit
Time Limit
128MB
Memory Limit
Memory Limit
Code Editor
Register to Access Code Editor
Create a free account to solve coding problems and track your progress.
Register Now