BUYING2 Problem from easy section

Implemented solution
What I did in my solution was to store the values of prefix sums of the provided banknote values in a separate array. Then I just divide each value in the prefix sum array by the cost of single piece of sweet and store the max value in the mx variable. If the max value occurs more than once then I print -1 else I print the value of mx variable. This approach is giving correct answer on the example test case but is failing on the hidden test cases. Kindly help me understand where I am going wrong.