Guys I'm having trouble solving this question. I gave it a lot of thought but sadly I couldn't come up with a way to go about it. I thought of dynamic programming and specifically Rod Cutting. If anyone could just help me visualize it better and some better idea if not the algorithm or code.

A programmer wants to test whether or not n given conditions are all simultaneously true (e.g he may want to test whether both x>0 and y<z^2, but it is not clear which condition should be tested first. Suppose that it costs Ti units of time to check condition i and that the condition will be true with probability Pi, independent of the outcomes of all other conditions. In which order he should make the test in the best possible manner.