You are given an integer n. A perfectly straight street is represented by a number line ranging from 0 to n - 1.
You are given a 2D integer array lights representing the street lamps on the street. Each lights[i] = [positioni, rangei] indicates that there is a street lamp at position positioni that lights up the area from [max(0, positioni - rangei), min(n - 1, positioni + rangei)] (inclusive).
The brightness of a position p is defined as the number of street lamps that light up the position p.
You are given a 0-indexed integer array requirement of size n where requirement[i] is the minimum brightness of the ith position on the street.
Return the number of positions i on the street between 0 and n - 1 that have a brightness of at least requirement[i].
Input & Output
Constraints
- 1 ≤ n ≤ 105
- 1 ≤ lights.length ≤ 105
- 0 ≤ positioni < n
- 0 ≤ rangei ≤ 105
- requirement.length == n
- 0 ≤ requirement[i] ≤ 105