To meet the ever-growing demands of his cows,Farmer John has bought them a new soda machine. He wants to figure out the perfect place to install the machine.
The field in which the cows graze can be represented as a one-dimensional
number line. Cow i grazes in the range ( ) (a range that includes its endpoints),
and FJ can place the soda machine at any integer point in the range . Since cows are extremely lazy and try to moveas little as possible, each cow would like to have the soda machineinstalled within her grazing range.
Sadly, it is not always possible to satisfy every cow's desires.Thus FJ would like to know the largest number of cows that can besatisfied.
To demonstrate the issue, consider four cows with grazing ranges
and ; below is a schematic of their grazing
ranges:
As can be seen, the first, second and fourth cows share the point ,but the third cow's grazing range is disjoint. Thus, a maximum of cows can have the soda machine within their grazing range.