now ques seems so simple don't know why i afraid first after seeing it in contest
@Anonymous____________A721 Жыл бұрын
🤣
@wasurvivor Жыл бұрын
I think the binary search solution fails if we think logically. Let me give you a test case n = 3, k = 3 Composition = [[1,1,10],[2,2,5]] Stock = [0,0,50] Cost = [1,1,1] budget = 20 Binary search solution will return 5 because it will choose 1st machine and will make 5 alloys that will cost around (5*2) = 10 and our stocks array will be [0,0,0] and budget will become (20-10) = 10. Still using this 10 we can make one alloy using another machine (5+2+2). Please rectify me if I am wrong.
@saujanyasolanki4242 Жыл бұрын
If you read the description carefully you will see there is a highlighted line in question that tells 'All alloys must be created with same machine' so we cannot use the remaining budget on another machine
@DreamFist Жыл бұрын
ans=max(ans,res) in maxNumberOfAlloys is not needed ,as we are always incrementing l whenever we find a satisfying budget hence always increasing nature.Please correct me if i am wrong.
@anubhavnegi4230 Жыл бұрын
nope res might be incrementing for a particular value in composition while we carry out the binary search but it might change for the next value in composition as we might get a lesser value of res the the previous one so ans is required