Find the minimum number of cows Jack needs so that, against adversarial farms, he secures the required count of each bean kind.
Hard8Game theoryDynamic programmingGreedyNo attempts yetTime limit3sMemory limit512 MBA stranger handed Jack a bag of ordinary beans and told him that if he collects the required number of beans of every kind, he can grow a giant beanstalk and climb it to the treasure at the top.
Jack has to get the missing beans from the other farms in his village. Each farm grows a fixed set of bean kinds. When Jack asks a farm for a bean, that farm gives him exactly one bean, but Jack is not paying for it, so the farm picks the kind. It can hand over any kind it grows, and it can pick a different kind on every visit. Jack may visit any farm as many times as he likes.
The stranger takes cows too. For one cow Jack gets one bean of any kind he names.
Jack wants no chance of failure. Assume every farm picks the kind that hurts Jack the most, every time. What is the smallest number of cows Jack must bring so that he ends up with at least the required number of beans of every kind, whatever the farms pick?