Defective pens problem

Question

Hints

Answer