# Help in ZCO12002

Hello guys,
I m trying to do this program where I used bisect_left, bisect_right for upperbound and lowerbound binary search, but the program seems not pass all the test cases, please kindly help me to understand what’s wrong.

I tried debugging for almost 5 Hr yesterday, couldn’t do so, also this is my first post.

Thanks regards.

Below is the code:

import sys

from bisect import bisect_left, bisect_right

# finding greatest value smaller than X

def BinarySearchUpperBound(a, x):
i = bisect_left(a, x)
if i:
return (i-1)
else:
return -1

# lower bound search on W

def BinarySearchLowerBound(a, x):
i = bisect_right(a, x)
if i:
return (i-1)
else:
return -1

t, n, m = map(int, input().split())

contest = []

for i in range(t):
contest.append(list(map(int, input().split())))

V = list(map(int, input().split()))
W = list(map(int, input().split()))

minSum = sys.maxsize

V.sort()
W.sort()

for i in contest:
j = BinarySearchUpperBound(V, i[0])
k = BinarySearchLowerBound(W, i[1])
if j != -1 and k != -1:
minSum = min(minSum, (W[k]-V[j])+1)

print(minSum)

I would have helped you but I didn’t get what you’re trying to do because you messed up your code with explanation…
It would be cleaner if you wrote only your algorithm here (because it is language independent ) and provide a link to your code (you can post a link to your submission like this guy did or you can use pastebin)
even better if you post link to question otherwise one to need search for the question himself to answer to you ( which is kinda irritating ).

Also there is no submission for ZCO12002 in your recent activities

Thank you so much for going to such a extent for helping me out, yes it was dumb mistake on my part not to put question and putting just the logic of the code, this was my first time doing this, sorry.

Also I figured out the mistake, thank you for much for replying tho.

np
Good Luck with future queries…