Cannot figure out test cases which are not working

Hello everyone,
I am trying to solve the practice problem : CAMPON

My code works on the sample test case. However, I cannot think of the test cases which are not passing.
Can some please help me figure it out. TIA :slight_smile:

t = int(input())

for _ in range(t):
	d = int(input())
	schedule = []
	for i in range(d):
		a,b = map(int,(input().split()))
	schedule = sorted(schedule)

	for i in range(1,len(schedule)):
		schedule[i][1] = schedule[i][1]+schedule[i-1][1]

	q = int(input())
	scenarios = {}
	for j in range(q):
		a,b = map(int,(input().split()))

	for q in scenarios:
		flag = 0

		for elem in schedule:
			if elem[0]<=q:
				if elem[1]>=scenarios[q]:
		if flag == 1:
			print("Go Camp")
			print("Go Sleep")

Answer the queries online, donโ€™t store them. This is creating an issue because the number of queries are at max 100 and the number of days are 31. There is obviously a case where two or more queries have the same day and different or same req.
For example :
4 2
1 6
10 4
20 4
20 1857
20 84
There are in total 3 queries but your code will answer only the second one.
Moreover, I am not sure about the logic you used. I am not sure about it correctness.
Have a look at my code , here


The pigeon hole principle :relieved:.

1 Like

Thanks Aayush!
That was precisely it, instead of storing queries I checked it on a per input basis and all test cases were passed

Thanks ! I didnโ€™t realize that there might be multiple queries with same value.

1 Like