ranis-job

Rani works at sweet shop and is currently arranging sweets i.e. putting sweets in boxes. There are some boxes which contains sweets initially but they are not full. Rani have to fill boxes completely thereby minimizing the total no. of boxes.
You are given N no. of boxes, their initial amount and total capacity in grams. You have to print out the minimum no. of boxes required to store given amount of sweets.

Input:
First line contains no. of test cases. Each test case contains N no. of boxes and next two lines contains  n values each denoting their initial amount and total capacity.
Output:
Print out the minimum no. of boxes required to store given amount of sweets.

SAMPLE INPUT
2
3
300 525 110
350 600 115
6
1 200 200 199 200 200
1000 200 200 200 200 200

SAMPLE OUTPUT
2
1

Explanation

Testcase 1:
One way to pack the sweets onto as few boxes as possible is as follows. First, move 50 g from box 3 to box 1, completely filling it up. Next, move the remaining 60 g from box 3 to box 2. There are now two boxes which contain sweets after this process, so your output should be 2.
Testcase 2:
One way to consolidate the sweets would be to move the 1 g from box 1 to box 4. However, this is a poor choice, as it results in only one free box and five boxes which still contain sweets. A better decision is to move all the sweets from the other five boxes onto box 1. Now there is only one box which contains sweets. Since this is the optimal strategy, the output should be 1.

Difficulty: UNKNOWN_DIFFICULTY

Starter code:

Solutions:
def main():
	t=int(input())
	while t!=0:
		n=int(input())
		amt=input().split(" ")
		cap=input().split(" ")
		total_amt=0
		for i in range(n):
			total_amt+=int(amt[i])
		#print total_amt
		cap=sorted(cap,key=int,reverse=True)
		#print cap
		for i in range(n):
			total_amt-=int(cap[i])
			if total_amt<=0:
				break
			#print total_amt
		print(i+1)
		t=t-1
if __name__=='__main__':
	main()


for _ in range(eval(input())):
	n=eval(input())
	s=sum(map(int,input().split()))
	a=list(map(int,input().split()))
	a.sort()
	i=0
	while s>0:
		s-=a[n-1-i]
		i+=1
	print(i)


class DiskSpace:
	def minDrives(self, used, total):
		used=tuple(map(int,used.split()))
		total=tuple(map(int,total.split()))
		s=sum(used)
		total=sorted(total,reverse=True)
		i=0
		while s>0:
			s-=total[i]
			i+=1
		return i

d=DiskSpace()
for tc in range(eval(input())):
	n=eval(input())
	print((d.minDrives(input(),input())))


t=eval(input())
for _ in range(t):
	n=eval(input())
	a=list(map(int,input().split()))
	b=list(map(int,input().split()))
	b.sort()
	x=sum(a)
	s=k=0
	for i in range(0,len(b)):
		y=len(b)-i-1
		s+=b[y]
		k+=1
		if(s>=x):
			print(k)
			break


for i in range(int(input())):
	n=int(input())
	a=list(map(int,input().split()))
	b=list(map(int, input().split()))
	count=1
	x=sum(a)
	b=sorted(b)
	b=b[::-1]
	s=0
	for j in range(len(b)):
		s+=b[j]
		if s>=x:
			print(count)
			break
		else:
			count+=1


class DiskSpace:
	def minDrives(self, used, total):
		#print(used,total)
		used=list(map(int,used.split()))
		total=list(map(int,total.split()))
		s=sum(used)
		total=sorted(total,reverse=True)
		i=0
		while s>0:
			s-=total[i]
			i+=1
		#print(i)
		return i

d=DiskSpace()
for tc in range(eval(input())):
	n=eval(input())
	u=input()
	v=input()
	print((d.minDrives(u,v)))