bzoj#P3314. [Usaco2013 Nov] Crowded Cows
[Usaco2013 Nov] Crowded Cows
Description
Farmer John's cows are grazing along a one-dimensional fence. Cow i 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
Line : Two integers, and .
Lines : Line contains the integers and . The locations of all cows are distinct.
Output
Line : The number of crowded cows.
6 4
10 3
6 2
5 3
9 7
3 6
11 2
2
Sample Explain 1
There are cows, with a distance threshold of for feeling crowded. Cow # lives at position and has height , and so on.
The cows at positions and are both crowded.
Data scale and Agreement
For data, , .
Source
Silver