1

Given $n$ drugs such that each drug $d_i$ should maintain in interval $[c_i,h_i]$.We want to minimize number of containers to maintain medicines in compatible interval.

My answer is as follows:

I use following greedy algorithm:

in each iteration, for remaining drugs, find an interval that have maximum number of compatible drugs, and remove that drugs, and add to container.

any one can help to find an counter example or proving above idea?

1 Answers1

0

Here is a counterexample.

There are 6 drugs with intervals $$[1, 5],\ [2,8],\ [3,8]$$ and $$[6, 11], \ [6,12],\ [9, 13].$$

We can use containers of volume 4 to cover the first 3 drugs and containers of volume 10 to cover the last 3 drugs. So it is enough to use 2 kinds of containers.

If we use the greedy algorithm, we would first cover $$[2,8],\ [3,8],\ [6, 11], \ [6,12]$$ using, for example, containers of volume 7. And then the remaining two intervals $$[1,5],\ [9,13]$$ that are disjoint will need additional two containers of different volumes to cover.

John L.
  • 38,985
  • 4
  • 33
  • 90