Bakery
Steps to solving:
Binary search for the minimum number of moonies paid p that will satisfy the constraints.
(C is the original time per cookie and M is the original time per muffin. c and m are the respective new times.)
Constraints:
both c and m need to be between 1 and their C, M respectively
c + m = C + M - p
The values c and m should satisfy all of Bessie's friends
To pass all test cases, the hardest part is to find whether there are cs and ms that satisfy the constraints for a given p without brute forcing over all possible values.
Last updated