Try to figure out the maximum number of **1’s**(number of times the panel is broken) that can be encountered while finding **x**.

You have 1000 coins, each time you find panel broken you have to pay **c** coins which are 150 in the worst case. So at max you can get **floor(1000/150)** **1’s** i.e **6**. So while interacting at runtime with the chef you can get only 6 1’s if you get 7th 1 you will not be able to find the answer. If you apply the binary search it iterates (log2 n) where n can be 150000 in the worst case, **(log2 150000) comes out to be greater than 17. ** So there will be a point where a chef will return -1 i.e your coins will be finished and you will not be able to find the answer before that, thus you must be getting WA in the first and third test case.

As you stated that you are modifying the ratio and then applying binary search, try to figure out the maximum iterations where you can get 1, that can help you I guess.