Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.

A football competition has just finished. The players have been given points for scoring goals and points for committing fouls. Now, it is up to Alex to find the best player in the tournament. As a programmer, your job is to help Alex by telling him the highest number of points achieved by some player.

You are given two sequences $A_{1}, A_{2}, \ldots, A_{N}$ and $B_{1}, B_{2}, \ldots, B_{N}$. For each valid $i$, player $i$ scored $A_{i}$ goals and committed $B_{i}$ fouls. For each goal, the player that scored it gets $20$ points, and for each foul, $10$ points are deducted from the player that committed it. However, if the resulting number of points of some player is negative, this player will be considered to have $0$ points instead.

You need to calculate the total number of points gained by each player and tell Alex the maximum of these values.

------  Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first line of each test case contains a single integer $N$.
The second line contains $N$ space-separated integers $A_{1}, A_{2}, \ldots, A_{N}$.
The third line contains $N$ space-separated integers $B_{1}, B_{2}, \ldots, B_{N}$.

------  Output ------
For each test case, print a single line containing one integer ― the maximum number of points.

------  Constraints  ------
$1 ≤ T ≤ 100$
$1 ≤ N ≤ 150$
$0 ≤ A_{i} ≤ 50$ for each valid $i$
$0 ≤ B_{i} ≤ 50$ for each valid $i$

------  Subtasks ------
Subtask #1 (30 points): $1 ≤ N ≤ 2$

Subtask #2 (70 points): original constraints

----- Sample Input 1 ------ 
2

3

40 30 50

2 4 20

1

0

10
----- Sample Output 1 ------ 
800

0
----- explanation 1 ------ 
Example case 1: The first player gets $800$ points for scoring goals and has $20$ points deducted for fouls. Likewise, the second player gets $560$ points and the third player gets $800$ points. The third player is the one with the maximum number of points.

Source: codechef | Difficulty: EASY
Tags: Implementation


Solutions:
def inputnums():
	line = input()
	words = line.split()
	nums = [int(w) for w in words]
	return nums
t = int(input())
for _ in range(t):
	n = int(input())
	a = inputnums()
	b = inputnums()
	s = 0
	for i in range(n):
		player = max(0, a[i] * 20 - b[i] * 10)
		s = max(s, player)
	print(s)


t = int(input())
for bunny in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = []
	for i in range(n):
		res = a[i] * 20 - b[i] * 10
		if res >= 0:
			l.append(res)
		else:
			l.append(0)
	print(max(l))


t = int(input())
for bunny in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(n):
		a[i] = a[i] * 20 - b[i] * 10
		if a[i] < 0:
			a[i] = 0
	print(max(a))


for _ in range(int(input())):
	n = eval(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	k = []
	for i in range(n):
		k.append(a[i] * 20 - b[i] * 10)
	if max(k) < 0:
		print(0)
	else:
		print(max(k))


y = int(input())
for i in range(y):
	n = int(input())
	lista = list(map(int, input().split()))
	listb = list(map(int, input().split()))
	l = []
	for i in range(len(lista)):
		sum = lista[i] * 20 - listb[i] * 10
		if sum < 0:
			sum = 0
		l.append(sum)
	print(max(l))


for _ in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	l = []
	for i in range(a):
		d = b[i] * 20 - c[i] * 10
		if d < 0:
			l.append(0)
		else:
			l.append(d)
	print(max(l))


for i in range(int(input())):
	a = int(input())
	l = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	t = []
	u = []
	for j in range(a):
		y = l[j] * 20
		z = l1[j] * 10
		u.append(z)
		t.append(y)
	q = []
	for p in range(a):
		w = t[p] - u[p]
		q.append(w)
	o = max(q)
	if o > 0:
		print(o)
	else:
		print('0')


n = int(input())
for i in range(n):
	n1 = int(input())
	l = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = []
	for i in range(len(l)):
		l3.append(l[i] * 20 - l2[i] * 10)
	if max(l3) < 0:
		print(0)
	else:
		print(max(l3))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sum = []
	for i in range(0, len(a)):
		sum.append(a[i] * 20 - b[i] * 10)
	if max(sum) <= 0:
		print(0)
	else:
		print(max(sum))


T = int(input())
for i in range(0, T):
	N = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	l = []
	for j in range(N):
		x = 20 * A[j] - 10 * B[j]
		if x < 0:
			l.insert(j, 0)
		else:
			l.insert(j, x)
	l.sort()
	print(l[len(l) - 1])
	l.clear()


for i in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	f = list(map(int, input().split()))
	l1 = [i * 20 for i in s]
	l2 = [i * 10 for i in f]
	k = []
	for i in range(n):
		k.append(l1[i] - l2[i])
	if max(k) > 0:
		print(max(k))
	else:
		print(0)


s = int(input())
for i in range(s):
	a = int(input())
	n = list(map(int, input().split(' ')))
	m = list(map(int, input().split(' ')))
	lst = []
	for j in range(a):
		z = n[j] * 20 - m[j] * 10
		if z < 0:
			z = abs(z) + z
			lst.append(z)
		else:
			lst.append(z)
	print(max(lst))


t = int(input())
for j in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	m = -1
	for i in range(n):
		m = max(20 * a[i] - 10 * b[i], m)
	if m < 0:
		print(0)
	else:
		print(m)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = []
	for i in range(0, n):
		x = a[i] * 20 - b[i] * 10
		if x > 0:
			c.append(x)
		else:
			c.append(0)
	print(max(c))


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	c = Counter({i: x for (i, x) in enumerate(list(map(int, input().split())))})
	d = Counter({i: x for (i, x) in enumerate(list(map(int, input().split())))})
	c20 = Counter()
	for i in range(20):
		c20 += c
	d10 = Counter()
	for i in range(10):
		d10 += d
	res = c20 - d10
	res2 = res.most_common(1)[0][1] if res else 0
	print(res2)


t = int(input())
while t != 0:
	t = t - 1
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	m = 0
	for i in range(n):
		ans = a[i] * 20 - b[i] * 10
		m = max(m, ans)
	print(m)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = 0
	for i in range(n):
		d = a[i] * 20 - b[i] * 10
		c = max(d, c)
	print(c)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	p = 0
	for i in range(n):
		p = max(p, a[i] * 20 - b[i] * 10)
	print(p)


for i in range(int(input())):
	n = int(input())
	max1 = 0
	lst1 = list(map(int, input().split()))
	lst2 = list(map(int, input().split()))
	for i in range(n):
		a = lst1[i] * 20 - lst2[i] * 10
		if a > max1:
			max1 = a
	print(max1)


for j in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	c = []
	for i in range(N):
		x = A[i] * 20 - B[i] * 10
		if x > 0:
			c.append(x)
		else:
			c.append(0)
	print(max(c))


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()[:n]))
	y = list(map(int, input().split()[:n]))
	k = 0
	for i in range(n):
		r = x[i] * 20 - y[i] * 10
		if r > k:
			k = r
	print(k)


for i in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l = []
	for i in range(n):
		if 20 * l1[i] - 10 * l2[i] <= 0:
			l.append(0)
		else:
			l.append(20 * l1[i] - 10 * l2[i])
	print(max(l))


for _ in range(int(input())):
	n = int(input())
	goal = list(map(int, input().split()))
	foul = list(map(int, input().split()))
	m = 0
	for i in range(n):
		a = goal[i] * 20 - foul[i] * 10
		m = max(m, a)
	print(m)


for i in range(int(input())):
	N = int(input())
	goals = list(map(int, input().split()))
	fouls = list(map(int, input().split()))
	mop = 0
	for j in range(N):
		temp = goals[j] * 20 - fouls[j] * 10
		if temp < 0:
			temp = 0
		if mop <= temp:
			mop = temp
	print(mop)


n = int(input())
for _ in range(n):
	a = int(input())
	l = list(map(int, input().split()))
	b = list(map(int, input().split()))
	f = []
	s = 0
	for i in range(a):
		s = l[i] * 20 - b[i] * 10
		if s >= 0:
			f.append(s)
		else:
			f.append(0)
	print(max(f))


for i in range(int(input())):
	n = int(input())
	arr1 = [20 * int(j) for j in input().split()]
	arr2 = [-10 * int(j) for j in input().split()]
	arr3 = []
	for j in range(n):
		arr3.append(arr1[j] + arr2[j])
	maxi = max(arr3)
	if maxi > 0:
		print(maxi)
	else:
		print(0)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	max_score = 0
	for i in range(n):
		res = a[i] * 20 - b[i] * 10
		if res > max_score:
			max_score = res
	print(max_score)


t = int(input())
for i in range(t):
	li = []
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	for j in range(n):
		a = A[j] * 20 - B[j] * 10
		if a < 0:
			li.append(0)
		else:
			li.append(a)
	print(max(li))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	mx = 0
	for i in range(n):
		mx = max(mx, 20 * a[i] - 10 * b[i])
	print(mx)


for i in range(int(input())):
	num = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = []
	for i in range(num):
		g = a[i] * 20
		f = b[i] * 10
		t = g - f
		if t > 0:
			l.append(t)
		else:
			l.append(0)
	print(max(l))


t = int(input())
for i in range(t):
	n = int(input())
	p1 = list(map(int, input().split()))
	p2 = list(map(int, input().split()))
	score = []
	for i in range(len(p1)):
		for j in range(len(p2)):
			if i == j:
				val = p1[i] * 20 - p2[j] * 10
				if val < 0:
					score.append(0)
				score.append(val)
	player = max(score)
	print(player)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = []
	for i in range(n):
		goal = a[i] * 20
		foul = b[i] * 10
		total = goal - foul
		if total > 0:
			l.append(total)
		else:
			l.append(0)
	print(max(l))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = []
	for i in range(n):
		c.append(20 * a[i] - 10 * b[i])
	c.sort()
	if c[-1] < 0:
		print('0')
	else:
		print(c[-1])


t = int(input())
for _ in range(t):
	n = int(input())
	goals = list(map(int, input().split()))
	fouls = list(map(int, input().split()))
	max_points = 0
	for i in range(n):
		points = goals[i] * 20 - fouls[i] * 10
		max_points = max(max_points, max(points, 0))
	print(max_points)


q = int(input())
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = []
	for j in range(n):
		l.append(a[j] * 20 - b[j] * 10)
	for k in range(n):
		if l[k] < 0:
			l[k] = 0
	print(max(l))


t = int(input())
for i in range(t):
	n = int(input())
	arr_a = list(map(int, input().split()))
	arr_b = list(map(int, input().split()))
	final_arr = []
	for (x, y) in zip(arr_a, arr_b):
		goals = x * 20
		fouls = y * 10
		z = goals - fouls
		final_arr.append(z)
	if max(final_arr) > 0:
		print(max(final_arr))
	else:
		print('0')


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c2 = 0
	for i in range(len(a)):
		c1 = a[i] * 20 - b[i] * 10
		if c2 < c1:
			c2 = c1
	print(c2)


for i in range(int(input())):
	N = int(input())
	Points = 0
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	for i in range(N):
		if A[i] * 20 - B[i] * 10 > Points:
			Points = A[i] * 20 - B[i] * 10
	print(Points)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	countt = []
	for i in range(n):
		z = abs(a[i] * 20) - b[i] * 10
		if z > 0:
			countt.append(z)
		elif z < 0:
			countt.append(0)
	print(max(countt))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	k = list(map(int, input().split()))
	b = []
	for i in range(n):
		b.append(l[i] * 20 - k[i] * 10)
	c = max(b)
	if c > 0:
		print(c)
	else:
		print(0)


t = int(input())
for _ in range(t):
	n = int(input())
	array_a = list(map(int, input().split()))
	array_b = list(map(int, input().split()))
	scores = [0] * n
	for i in range(n):
		scores[i] = array_a[i] * 20 - 10 * array_b[i]
		if scores[i] < 0:
			scores[i] = 0
	print(max(scores))


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = []
	for i in range(n):
		k = a[i] * 20 - b[i] * 10
		if k < 0:
			k = 0
		c.append(k)
	print(max(c))


tc = int(input())
for _ in range(tc):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	scores = []
	for i in range(n):
		s = 20 * a[i] - 10 * b[i]
		if s < 0:
			s = 0
		scores.append(s)
	print(max(scores))


t = int(input())
for tc in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = 20
	c = []
	for j in range(n):
		d = a[j] * 20 - b[j] * 10
		c.append(d)
	if max(c) > 0:
		print(max(c))
	else:
		print('0')


for tc in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = []
	for i in range(n):
		l.append(a[i] * 20 - b[i] * 10)
	if max(l) < 0:
		print(0)
	else:
		print(max(l))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	highest_score = 0
	for i in range(n):
		total_score = a[i] * 20 - b[i] * 10
		if total_score > highest_score:
			highest_score = total_score
	if highest_score < 0:
		print(0)
	else:
		print(highest_score)


for _ in range(int(input())):
	x = int(input())
	y = list(map(int, input().split()))
	z = list(map(int, input().split()))
	p = []
	for val in range(x):
		p.append(y[val] * 20 - z[val] * 10)
	if max(p) > 0:
		print(max(p))
	else:
		print(0)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	h = []
	for i in range(n):
		g = a[i] * 20 - b[i] * 10
		h.append(g)
	if max(h) > 0:
		print(max(h))
	else:
		print(0)


for _ in range(int(input())):
	l = int(input())
	a = [int(x) for x in input().split()]
	b = [int(y) for y in input().split()]
	ans = []
	for i in range(l):
		res = a[i] * 20 - b[i] * 10
		if res < 0:
			ans.append(0)
		else:
			ans.append(res)
	print(max(ans))


for i in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	k = []
	for i in range(n):
		k.append(a[i] * 20 - b[i] * 10)
	if max(k) > 0:
		print(max(k))
	else:
		print(0)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	r = 0
	mx = 0
	while r < len(a):
		ia = a[r]
		ib = b[r]
		y = ia * 20 - ib * 10
		r += 1
		if y > mx:
			mx = y
	print(mx)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	m = -1000000000
	for i in range(n):
		t = a[i] * 20 - b[i] * 10
		if t < 0:
			t = 0
		m = max(t, m)
	print(m)


T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = []
	for i in range(n):
		c = a[i] * 20 - b[i] * 10
		if c < 0:
			c = 0
		d.append(c)
	print(max(d))


t = int(input())
for m in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = []
	for i in range(n):
		d = 20 * a[i] - 10 * b[i]
		if d < 0:
			c.append(0)
		else:
			c.append(d)
	print(max(c))


for _ in range(int(input())):
	players = int(input())
	goallist = list(map(int, input().split()))
	foullist = list(map(int, input().split()))
	scorelist = []
	for i in range(players):
		goalscore = 20 * goallist[i]
		foulscore = 10 * foullist[i]
		netscore = goalscore - foulscore
		scorelist.append(netscore)
		maxscore = max(scorelist)
		if maxscore < 0:
			maxscore = 0
	print(maxscore)


t = int(input())
for i in range(t):
	n = int(input())
	h = []
	l = list(map(int, input().split()))
	m = list(map(int, input().split()))
	for i in range(n):
		h.append(l[i] * 20 - m[i] * 10)
	maxi = max(h)
	if maxi < 0:
		maxi = 0
	print(maxi)


for i in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l = list()
	for j in range(n):
		s = l1[j] * 20
		t = l2[j] * 10
		h = s - t
		l.append(h)
	if max(l) > 0:
		print(max(l))
	else:
		print(0)


cases = int(input())
for i in range(cases):
	numPlayers = int(input())
	goals = list(map(int, input().split()))
	fouls = list(map(int, input().split()))
	pointsArray = []
	for j in range(numPlayers):
		points = 20 * goals[j] - 10 * fouls[j]
		if points < 0:
			points = 0
		pointsArray.append(points)
	print(max(pointsArray))


T = int(input())
while T > 0:
	N = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	initial = 0
	total = 0
	answer = 0
	for i in range(N):
		total = A[i] * 20 - B[i] * 10
		if total > initial:
			answer = total
			initial = total
	print(answer)
	T -= 1