Advertisement
Guest User

Untitled

a guest
Nov 16th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. def con():
  2. t=int(input())
  3. for i in range(t) :
  4. a=list()
  5. b=list()
  6. n= int( input() )
  7. ch1=input()
  8. a=[ int(j) for j in ch1.split() ]
  9. ch2=input()
  10. b=[int(j) for j in ch2.split()]
  11. if ch1==ch2:
  12. print("YES")
  13. continue
  14. k=0
  15. B=True
  16. while((B==True)and(k<n)) :
  17. if a[k]>b[k] :
  18. B=False
  19. elif a[k]<b[k] :
  20. tmp=b[k]-a[k]
  21. v=k
  22. B1=True
  23. while(B1==True) :
  24. if ((b[v]==tmp+a[v])) :
  25. v=v+1
  26. else :
  27. k=v
  28. B1=False
  29. for l in range(k,n):
  30. if ( a[l] == b[l] ):
  31. continue
  32. else:
  33. B=False
  34. else:
  35. k=k+1
  36. if (B==True ):
  37. print("YES")
  38. else :
  39. print("NO")
  40.  
  41. con()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement