my code is correct but somehow it is working only for a single output:cry:
PLEASE COMMENT AND CORRECT MY CODE
https://ide.codingblocks.com/s/41024
questn link
https://hack.codingblocks.com/contests/c/512/1226
my code is correct but somehow it is working only for a single output:cry:
PLEASE COMMENT AND CORRECT MY CODE
https://ide.codingblocks.com/s/41024
questn link
https://hack.codingblocks.com/contests/c/512/1226
Refer to this link
???
i am not using any array
PLEASE COMMENT ON MY CODE
Okay , go through this , i have modified ur binary search function
https://ide.codingblocks.com/s/41069
i have further corrected my code
https://ide.codingblocks.com/s/41080
tried many test cases it works perfectly and still on submission am getting 3 wrong answers
PLEASE TELL ME WHAT ALL TEST CASES MY CODE ISNT PASSING
Your logic is right.
But you need to look at the constraints of the problem carefully. Such big constraints can’t be handled by int…
while (l <= r) {
mid = (l + r) / 2;
if ((mid * x) <= m + ((n - mid) * y)) {
ans = mid;
l = mid + 1;
} else {
r = mid - 1;
}
}
You can refer to this simple pseudocode for any guidance
Sir can you please explain that why we are applying binary search in this problem??
Actually i am not understanding the need of binary search in this problem
Look at the constraints of the question
1 ≤ N,M,X,Y ≤ 10^9
This would give TLE in O(n), i.e. Linear Search. It can be solved in O(log n). Thus we used Binary Search.