#P3088. [USACO13NOV] Crowded Cows S
[USACO13NOV] Crowded Cows S
Description
Farmer John's cows () are grazing along a one-dimensional fence. Cow is standing at location and has height ().
A cow feels "crowded" if there is another cow at least twice her height within distance on her left, and also another cow at least twice her height within distance on her right (). Since crowded cows produce less milk, Farmer John would like to count the number of such cows. Please help him.
Input Format
-
Line : Two integers, and .
-
Lines : Line contains the integers and . The locations of all cows are distinct.
Output Format
- Line : The number of crowded cows.
6 4
10 3
6 2
5 3
9 7
3 6
11 2
2
Hint
There are cows, with a distance threshold of for feeling crowded. Cow #1 lives at position and has height , and so on.
The cows at positions and are both crowded.
京公网安备 11011102002149号