fork download
  1. # your code goes here
  2. t= int(input())
  3. for i in range(t):
  4. n,q = map(int,input().split(" "))
  5. l=list(map(int,input().strip().split(' ')))
  6. for j in range(q):
  7. count=0
  8. count1=0
  9. add=0
  10. k=int(input().strip())
  11. t=sorted(l,reverse=True)
  12. r=list(z-k for z in t)
  13. for w in r:
  14. if w>=0:
  15. count= count+1
  16. else:
  17. add=add+abs(w)
  18. if add<(n-count):
  19. count1=count1+1
  20. print(count+count1)
  21.  
  22.  
  23.  
Success #stdin #stdout 0.02s 27704KB
stdin
1
7 1
10 5 9 21 8 6 7
10
stdout
4