Today is a rainy day! Farmer John's N (1 <= N <= 5,000) cows, numbered
1..N, are not particularly fond of getting wet. The cows are standing in
roofless stalls arranged on a number line. The stalls span X-coordinates
from 1 to M (1 <= M <= 100,000). Cow i stands at a stall on coordinate
)
. No two cows share stalls.
In order to protect the cows from the rain, Farmer John wants to buy them
umbrellas. An umbrella that spans coordinates
)
has a
width of

It costs
)
to buy an
umbrella of width W. Larger umbrellas do not necessarily cost more than
smaller umbrellas.
Help Farmer John find the minimum cost it takes to purchase a set of
umbrellas that will protect every cow from the rain. Note that the set of
umbrellas in an optimal solution might overlap to some extent.