Help Required in BINARY SEARCH

Hello Sir, I understood the problem as large inputs are involved so binary_search() would be used and then followed by lower_bound()

Could you please tell me how I could reduce the search area in lower_bound(a,a+n,key)

Thanks very much :slight_smile:

We cannot reduce the search area in lower_bound function.lower_bound is stl function,so we cannot reduce the search area in lower_bound function.

@Mohitpandey29 Sir do you suggest the use of normal binary search function then?

By using simple lower_bound(a,a+n,key) I am able to get 50% testcases right. But since the constraints demand upto 10^19. What do you suggest Sir?

Binary search will work in this case to, but long long int can’t store 10^19, I think that is why it is not passing all test, you need to use string or different algorithm.