Time limit
2s
Memory limit
128 MB
After heavy rain, N puddles formed on a dirt road from a winter camp site to the main building. There are enough planks, each of length L, to cover the puddles. Given the start and end coordinate of every puddle, find the minimum number of planks needed to cover all puddles.
The first line contains two integers N and L.
Each of the next N lines contains the information for one puddle: its start coordinate and end coordinate. A puddle occupies the interval from its start coordinate up to, but not including, its end coordinate. Every coordinate is an integer between 0 and 1,000,000,000, inclusive. The given puddles do not overlap.
Print the minimum number of planks needed to cover all puddles.
The arrangement below needs five planks.
111222..333444555.... // planks of length 3.MMMMM..MMMM.MMMM.... // puddles012345678901234567890 // coordinates111222..333444555.... // planks of length 3.MMMMM..MMMM.MMMM.... // puddles012345678901234567890 // coordinates