Your company produces components used in construction. From time to time, it is necessary to run a series of tests on several of the components, to determine their breaking force. The goal of the testing is to determine the point at which the unit breaks, up to a given threshold. (Only integer forces are applied.)
You have a set of components to be used for testing. You are to find an optimal testing plan, minimizing the number of tests that will have to be performed (in the worst case). In the process of testing, you may destroy some or all of the test components, provided that in the end, the breaking force is known.
Unfortunately, no manufacturing process is perfect, so it is possible that one of your test components is defective. A defective component is defined as one that breaks under a lesser force than a typically produced component.
You are given int maxForce, the highest force at which you need to test the components. (They may have a higher breaking force than this, but you are not concerned with testing any higher force.) You are also given int testUnits, the number of units that are available for testing. You are to return the fewest number of tests necessary to conclusively determine the breaking force of a non-defective component.
|