Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def con():
- t=int(input())
- for i in range(t) :
- a=list()
- b=list()
- n= int( input() )
- ch1=input()
- a=[ int(j) for j in ch1.split() ]
- ch2=input()
- b=[int(j) for j in ch2.split()]
- if ch1==ch2:
- print("YES")
- continue
- k=0
- B=True
- while((B==True)and(k<n)) :
- if a[k]>b[k] :
- B=False
- elif a[k]<b[k] :
- tmp=b[k]-a[k]
- v=k
- B1=True
- while(B1==True) :
- if ((b[v]==tmp+a[v])) :
- v=v+1
- else :
- k=v
- B1=False
- for l in range(k,n):
- if ( a[l] == b[l] ):
- continue
- else:
- B=False
- else:
- k=k+1
- if (B==True ):
- print("YES")
- else :
- print("NO")
- con()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement