Problem:


Score : 200 points

Problem Statement

There are N gems. The value of the i-th gem is V_i.

You will choose some of these gems, possibly all or none, and get them.

However, you need to pay a cost of C_i to get the i-th gem.

Let X be the sum of the values of the gems obtained, and Y be the sum of the costs paid.

Find the maximum possible value of X-Y.

Constraints

All values in input are integers.

1 \leq N \leq 20

1 \leq C_i, V_i \leq 50

Input

Input is given from Standard Input in the following format:

N
V_1 V_2 ... V_N
C_1 C_2 ... C_N

Output

Print the maximum possible value of X-Y.

Sample Input 1

3
10 2 5
6 3 4

Sample Output 1

5

If we choose the first and third gems, X = 10 + 5 = 15 and Y = 6 + 4 = 10.
We have X-Y = 5 here, which is the maximum possible value.

Sample Input 2

4
13 21 6 19
11 30 6 15

Sample Output 2

6

Sample Input 3

1
1
50

Sample Output 3

0



Sample input:
3
10 2 5
6 3 4


Sample output:
5

Submission status: Accepted

Solution code:
import itertools
N = int(input())

test = {}

V = list(map(int,input().split()))
C = list(map(int,input().split()))
new_n = 0
for i in range(N):
    if V[i] <=  C[i]:
        continue
    else:
        test[i] = [V[i],C[i]]
        new_n += 1

N = new_n

def calc_cost(com,test,i):
    x = 0
    y = 0
    for j in com:
        x += test[j][0]
        y += test[j][1]
    return x - y

ans = 0

for i in range(N):
    c = itertools.combinations(test.keys(), i+1)
    for j in c:
        ans = max(ans,calc_cost(j,test,i))


print(ans)

Submission status: Accepted

Solution code:
n=int(input())

value=0
cost=0

v=list(map(int, input().split()))
c=list(map(int, input().split()))

for i in range(n):
    if v[i]>c[i]:
        value=value+v[i]
        cost=cost+c[i]

total=value-cost

print(total)

Submission status: Accepted

Solution code:
n = int(input())
value_list = list(int(x) for x in input().split())
cost_list = values = list(int(x) for x in input().split())
sum_v = 0
sum_c = 0

for i in range(n):
    if value_list[i] > cost_list[i]:
        sum_v += value_list[i]
        sum_c += cost_list[i]
    else:
        pass

ans = sum_v - sum_c
print(ans)

Submission status: Accepted

Solution code:

# B

n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

p = 0
for i in range(n):
    if v[i] > c[i]:
        p += v[i] - c[i]
print(p)

Submission status: Accepted

Solution code:
N=int(input())
VALUE= list(map(int,input().split()))
COST = list(map(int,input().split()))
COUNT=0

for i in range(0,N):
    CHECK = VALUE[i]-COST[i]
    if CHECK >= 0:
        COUNT+=CHECK

print(COUNT)

Submission status: Accepted

Solution code:
def spaceinput():
    return list(map(int,input().split(" ")))

N=int(input())
v=spaceinput()
c=spaceinput()

res=0
for i in range(N):
    if v[i]-c[i]>0:
        res+=v[i]-c[i]

print(res)

Submission status: Accepted

Solution code:
import queue

N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
ans = 0
for i in range(N):
	if A[i] - B[i] > 0:
		ans += A[i] - B[i]
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
v=list(map(int, input().split()))  #リスト入力
c=list(map(int, input().split()))  #リスト入力

v = np.array(v)
c = np.array(c)


venefit = v - c

venefit= venefit.tolist()
l_minus = [i for i in venefit if i > 0]

n = sum(l_minus)  # 真偽値リストを作って True の数を合計する方法
print(n)

Submission status: Accepted

Solution code:
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
print(sum(v[i]-c[i] for i in range(n) if((v[i]-c[i])>0)))

Submission status: Accepted

Solution code:
N=int(input())
V=[int(x) for x in input().split()]
C=[int(x) for x in input().split()]

Y=0
for x in range(N):
    Y+=max(0,V[x]-C[x])
print(Y)

Submission status: Accepted

Solution code:
N = int(input())
VC = [list(map(int,input().split())) for _ in range(2) ] 
ans = 0
for i in [ VC[0][_] - VC[1][_] for _ in range(N)]:
    if i> 0:
        ans+=i
print(ans)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    v = [int(s) for s in input().split()]
    c = [int(s) for s in input().split()]

    s = sum(max(x - y, 0) for x, y in zip(v, c))
    print(s)

main()

Submission status: Accepted

Solution code:
N = int(input())
V = [int(n) for n in input().split(" ")]
C = [int(n) for n in input().split(" ")]
ret = 0
for i in range(N):
    if V[i] - C[i] > 0:
        ret += V[i] - C[i]

print(ret)

Submission status: Accepted

Solution code:
import numpy as np
n = input()
v = np.array(input().split(), dtype=np.int64)
c = np.array(input().split(), dtype=np.int64)
e = v-c
print(sum(e[e>0]))

Submission status: Accepted

Solution code:
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))

score=0
for i in range (len(v)):
  if v[i]>c[i]:
    score +=v[i]-c[i]
    
print(score)

Submission status: Accepted

Solution code:
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
diffs = []
value = 0

for i in range(N):
    diffs.append(V[i]-C[i])

    if diffs[i]>0:
        value += diffs[i]

print(value)

Submission status: Accepted

Solution code:
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
for i in [ V[_] - C[_] for _ in range(N)]:
    if i> 0:
        ans+=i
print(ans)

Submission status: Accepted

Solution code:
def main():
  N = int(input())
  V = list(map(int, input().split(" ")))
  C = list(map(int, input().split(" ")))
  s = 0
  for i in range(N):
    if V[i] > C[i]:
        s += V[i] - C[i]
  print(s)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
value = list(map(int, input().split()))
cost = list(map(int, input().split()))
result = 0
for v, c in zip(value, cost):
  if v > c:
    result += v-c
print(result)

Submission status: Accepted

Solution code:
import numpy as np

def read_input():
    n = int(input())
    values = np.asarray(list(map(int, input().split())))
    costs = np.asarray(list(map(int, input().split())))

    return n, values, costs

if __name__ == '__main__':
    n, values, costs = read_input()
    benefits = values - costs
    benefits = np.sort(benefits)[::-1]

    benefits = [p for p in benefits if p > 0]
    benefits = benefits[:n]

    if benefits:
        print(sum(benefits))
    else:
        print(0)

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())

V = input().split()
C = input().split()
for i in range(N):
  V[i] = int(V[i])
  C[i] = int(C[i])

profit = 0
for i in range(N):
  if V[i] > C[i]:
    profit = profit + V[i] - C[i]
print(profit)

Submission status: Accepted

Solution code:
n = int(input())
lis = list(map(int,input().split()))
li = list(map(int,input().split()))
ans = 0
for i in range(n):
  ans += max(0,lis[i]-li[i])
print(ans)

Submission status: Accepted

Solution code:

N = int(input())
V = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

XY = 0

for i in range(N):
    if (V[i]-C[i]) > 0 :
        XY += V[i]-C[i]

print(XY)

Submission status: Accepted

Solution code:
n = int(input(), 10) 
v = list(map(int, input().split())) 
c = list(map(int, input().split())) 
otoku = []
 
for i in range(n):
  otoku.append(v[i] - c[i])
 
res = 0
for j in range(n):
  if otoku[j] > 0:
    res += otoku[j]
    
print(res)

Submission status: Accepted

Solution code:
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i in range(n):
    if v[i] > c[i]:
        ans += (v[i]-c[i])
    else:
        pass
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
v = map(int, input().split())
c = map(int, input().split())

print(sum([vi - ci for vi, ci in zip(v, c) if vi > ci]))

Submission status: Accepted

Solution code:
N = int(input())
v_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

value = 0
for v, c in zip(v_list, c_list):
    if v > c:
        value = value + v - c

print(value)

Submission status: Accepted

Solution code:
n = int(input())
liv = list(map(int,input().split()))
lic = list(map(int,input().split()))
ans = 0

for i in range(n):
    if liv[i] > lic[i]:
        ans += liv[i] - lic[i]

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
VC = []
for i in range(N):
    VC.append(V[i] -  C[i])
ans = 0
for j in VC:
    if j > 0:
        ans+=j
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

x = 0 # values
y = 0 # costs
diff = x - y

for i in range(len(V)):
    if x + V[i] - (y + C[i]) > diff:
        diff = x + V[i] - (y + C[i])
        x = x + V[i]
        y = y + C[i]


print(diff)

Submission status: Accepted

Solution code:
N = int(input())
V = [int(_) for _ in input().split()]
C = [int(_) for _ in input().split()]

count = 0
for i in range(N):
  if V[i]-C[i] > 0:
    count += V[i]-C[i]
    
print(count)

Submission status: Accepted

Solution code:
N=int(input())
V=map(int, input().split())
C=map(int, input().split())

t=0
for v,c in zip(V,C):
	if v > c:
		t += v-c

print(t)

Submission status: Accepted

Solution code:
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

N = ii()
V = li()
C = li()

max_val = 0
for i in range(N):
    if V[i] - C[i] > 0:
        max_val += V[i] - C[i]

print(max_val)

Submission status: Accepted

Solution code:
import re
import sys
from fractions import gcd
from functools import reduce
from itertools import product

import numpy as np

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    N = ii()
    V = il()
    C = il()
    ans = 0
    for v, c in zip(V, C):
        k = v - c
        if k > 0:
            ans += k
    return ans


if __name__ == "__main__":
    print(solve())

Submission status: Accepted

Solution code:
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
cnt = 0
for i in range(n):
    if v[i] > c[i]:
        cnt += (v[i] - c[i])
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
V = list(map(int, input().split( )))
C = list(map(int, input().split( )))
X = 0
for i in range(N):
    if(V[i]-C[i]>0):
        X += V[i] - C[i]
print(X)

Submission status: Accepted

Solution code:

N=int(input())
V=list(map(int,input().strip().split(' ')))
C=list(map(int,input().strip().split(' ')))

temp=0
for i in range(N):
    temp+=max(V[i]-C[i],0)
print(temp)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

N = int(input())
V = list(map(int, input().rstrip().split(' ')))
C = list(map(int, input().rstrip().split(' ')))

sum_value = 0
for i in range(N):
    if V[i] - C[i] > 0:
        sum_value += V[i] - C[i]
        
print(sum_value)

Submission status: Accepted

Solution code:
N = int(input())
V = [int(x.strip()) for x in input().split()]
C = [int(x.strip()) for x in input().split()]

Z = [V[i] - C[i] for i in range(N)]
print(sum([z for z in Z if z > 0]))

Submission status: Accepted

Solution code:
n = int(input())
vs = list(map(int, input().split()))
cs = list(map(int, input().split()))

total = 0
for i in range(n):
    if vs[i] > cs[i]:
        total += vs[i] - cs[i]

print(total)

Submission status: Accepted

Solution code:
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0

for i in range(n):
    ans = ans + max(v[i] - c[i], 0)

print(ans)

Submission status: Accepted

Solution code:
num = int(input())
jueries = input().split()
costs = input().split()
result = 0

for i in range(num):
  value = int(jueries[i])
  cost  = int(costs[i])
  target = value - cost
  if target > 0:
    result += target
print(result)

Submission status: Accepted

Solution code:
# coding: utf-8

number_of_jewels = int(input())
jewels_value = list(map(int, input().split()))
jewels_cost = list(map(int, input().split()))
ans = 0

jewels_value_minus_cost = [0 for i in range(number_of_jewels)]
for i in range(number_of_jewels):
    jewels_value_minus_cost[i] = jewels_value[i] - jewels_cost[i]
jewels_value_minus_cost.sort()
jewels_value_minus_cost.reverse()
for i in jewels_value_minus_cost:
    if i>0:
        ans += i
    else:
        break
print(ans)

Submission status: Accepted

Solution code:
N = input().split()
Vs = list(map(int, input().split()))
Cs = list(map(int, input().split()))

l = []
for i in range(0, len(Vs)):
  tmp = Vs[i] - Cs[i]
  l.append(0 if tmp < 0 else tmp )
  

print(sum(l))

Submission status: Accepted

Solution code:
_ = input()
V = list(map(int, input().split()))
C = list(map(int, input().split()))

result = 0
for v, c in zip(V, C):
    diff = v - c
    if diff > 0:
        result += diff 

print(result)

Submission status: Accepted

Solution code:
n = int(input())
v_list = list(map(int, input().split(" ")))
c_list = list(map(int, input().split(" ")))
total = 0
for i in range(n):
    if v_list[i] < c_list[i]:
        continue
    total += v_list[i] - c_list[i]
print(total)

Submission status: Accepted

Solution code:
n = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
val = 0
for i in range(0, n):
  if V[i] > C[i]:
    val += V[i] - C[i]
print(val)

Submission status: Accepted

Solution code:
N = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
s = 0
for  i in range(0,N):
    if v[i]-c[i] > 0:
        s += v[i]-c[i]
print(s)

Submission status: Accepted

Solution code:
# coding: utf-8

from itertools import combinations, chain

N = int(input())
values = map(int, input().split())
costs = map(int, input().split())

sales = [v - c for v, c in zip(values, costs)]

print(max(chain.from_iterable(map(sum, combinations(sales, i)) for i in range(0, N+1))))

Submission status: Accepted

Solution code:
n = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

def solve(ho, cost, cnt):
    if cnt == n:
        return ho - cost
    return max(solve(ho, cost, cnt + 1), solve(ho + V[cnt], cost + C[cnt], cnt + 1))

print(solve(0, 0, 0))

Submission status: Accepted

Solution code:
n = int(input())
v_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))
ans = 0

for i in range(n):
    if v_list[i] - c_list[i] > 0:
        ans += v_list[i] - c_list[i]

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
v_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

#n = 4
#v_list = [13, 21, 6, 19]
#c_list = [11, 30, 6, 15]

v_minus_c = [v-c for (v, c) in zip(v_list, c_list)]
total = sum([s for s in v_minus_c if s>0])
print(total)

Submission status: Accepted

Solution code:
import itertools
n = int(input())
v = list(map(int, input().split()))  # 入力のときに N を使う必要はありません
c = list(map(int, input().split()))  # 入力のときに N を使う必要はありません

answer = []

for i in range(n):
  answer.append(v[i] - c[i])
  
max = 0

for r in range(n+1):
    comb = list(itertools.combinations(answer, r))
    for j in comb:
        if max <= sum(j):
          max = sum(j)

print(max)

Submission status: Accepted

Solution code:
import itertools
import numpy as np

N = int(input())
V = [int(m) for m in input().split()]
C = [int(n) for n in input().split()]

X = 0
X_ = []
Y = 0
Y_ = []

for i in range(N):
    for value in itertools.combinations(V, i+1):
        X = sum(value)
        X_.append(X)

for j in range(N):
    for cost in itertools.combinations(C, j+1):
        Y = sum(cost)
        Y_.append(Y)
if max(np.array(X_)-np.array(Y_)) > 0:
    print(max(np.array(X_)-np.array(Y_)))
else:
    print(0)

Submission status: Accepted

Solution code:
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i in range(n):
    v[i] -= c[i]
for i in v:
    if i > 0:
        ans+=i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
V = list(int(i) for i in input().split())
C = list(int(i) for i in input().split())
R = list(range(N))
for i in range(N) :
  R[i-1] = V[i-1]-C[i-1] if V[i-1]-C[i-1] >=0 else 0
  
print(sum(R))

Submission status: Accepted

Solution code:
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
sum = 0

for i in range(n):
	if v[i] > c[i]:
		sum += v[i] - c[i]
	
print(sum)

Submission status: Accepted

Solution code:
n = int(input())
x=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]

ans = 0

for ind in range(n):
    if n == 1:
      break
    res = x[ind] - y[ind]
    if res > 0:
      ans += res

print(ans)

Submission status: Accepted

Solution code:
n= int(input())

v= list(map(int, input().split())) 
c= list(map(int, input().split()))
r=[]

for i in range(n):
  r.append(v[i]-c[i]) 

r.append(0)
r.sort(reverse=True)

ret= sum([j for j in r if j>=0])
print(ret)

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
V = list(map(int, input().strip().split()))
V = np.array(V)
C = list(map(int, input().strip().split()))
C = np.array(C)
B = 0
i = 0
while i <= N - 1:
    A = V[i] - C[i]
    i += 1
    if A > 0:
        B = B + A
print(B)

Submission status: Accepted

Solution code:
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
s = 0
for i in range(N):
    if V[i] > C[i]:
        s += V[i]-C[i]
print(s)

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
S = 0
for i in range(N):
  a = V[i] - C[i]
  if a >= 0:
    S = S + a
print(S)

Submission status: Accepted

Solution code:
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
d=0
for a,b in zip(v,c):
    if a-b>0:
        d+=a-b
print(d)

Submission status: Accepted

Solution code:
#宝石の数
N = int(input())
#宝石の価値
V = [int(i) for i in input().split()] 
#コスト
C = [int(i) for i in input().split()] 

X = 0
Y = 0

for i in range(N):
     if V[i] > C[i]:
         X += V[i]
         Y += C[i]
         
print(X-Y)

Submission status: Accepted

Solution code:
N = int(input())
vLst = list(map(int, input().split()))
cLst = list(map(int, input().split()))

total = 0
for i in range(N):
    if vLst[i] > cLst[i]:
        total += vLst[i] - cLst[i]
print(total)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

def main():
    n = int(input())
    V = [int(e) for e in input().split(" ")]
    C = [int(e) for e in input().split(" ")]

    N = [0 for i in range(n+1)]

    max_n = 0
    for i in range(1, n+1):
        prev = N[i-1]
        current = N[i-1] + (V[i-1] - C[i-1])
        if prev < current:
            N[i] = current
        else:
            N[i] = prev

    print(N[n])

main()

Submission status: Accepted

Solution code:
n = int(input())
v = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]

print(sum([x - y for x, y in zip(v, c) if x - y > 0]))

Submission status: Accepted

Solution code:
N = int(input())
a = input().split()
b = input().split()

sum = 0

for i in range(N):
  if int(a[i]) > int(b[i]):
    sum += int(a[i]) -int(b[i])

print(sum)

Submission status: Accepted

Solution code:
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
for i in range(N):
    tmp = V[i]-C[i]
#     print(tmp)
    if tmp > 0:
        ans += tmp
#     print(ans)
print(ans)

Submission status: Accepted

Solution code:
from functools import reduce
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(sum([max(0, a[i]-b[i]) for i in range(n)]))

Submission status: Accepted

Solution code:
n = int(input())
b = list(map(int,input().split()))
c = list(map(int,input().split()))
r=0
for i in range(n):
  if b[i]-c[i]>0:
    r = r + b[i] - c[i]
    
print(r)

Submission status: Accepted

Solution code:
import numpy as np
    
N=int(input())
V=np.array(list(map(int,input().split())))
C=np.array(list(map(int,input().split())))
XY=V-C
sum=0
i=0
while i<N:
    if XY[i]>0:
        sum+=XY[i]
    i+=1
    
print(sum)

Submission status: Accepted

Solution code:
number = int(input())
value = list(map(int, input().split()))
cost = list(map(int, input().split()))
total = 0

for i in range(number):
  if value[i] - cost[i] >= 0:
    total = total + (value[i] - cost[i])

print(total)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

n=int(input())
value=input().split(" ")
cost=input().split(" ")

res=0
for i in range(n):
    if int(value[i])-int(cost[i])>0:
        res+=int(value[i])-int(cost[i])
        
print(res)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

val = 0
for i in range(N):
    temp1 = A[i]
    temp2 = C[i]
    if temp1 - temp2 > 0:
        val += temp1 - temp2
print(val)

Submission status: Accepted

Solution code:
N = int(input())
V = [int(s) for s in input().split()]
C = [int(s) for s in input().split()]
ans = sum(max(0, V[i] - C[i]) for i in range(N))
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=0
for i in range(N):
    if V[i]>=C[i]:
        ans+=V[i]-C[i]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
sum = 0
for i in range(len(v)):
  if v[i] - c[i] > 0:
    sum += v[i] - c[i]
print(sum)

Submission status: Accepted

Solution code:
import itertools
import sys

n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

ids = [x for x in range(n)]

diff = [tmpv - tmpc for tmpv, tmpc in zip(v, c)]

result = 0

for i in range(1, n+1):
    tmp = list(itertools.combinations(diff, i))
    tmpMax = max([sum(x) for x in tmp])
    if tmpMax > result:
        result = tmpMax
    # store.extend([sum(x) for x in tmp])
    # print(store)
    # for x, y in zip(vset, cset):
    #     store.append(sum(x)-sum(y))

print(result)

Submission status: Accepted

Solution code:
def main() -> None:
    N = int(input())
    V = [int(x) for x in input().split()]
    C = [int(x) for x in input().split()]
    ans = 0
    for i in range(N):
        if V[i] > C[i]:
            ans += V[i] - C[i]
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = np.array(A)
D = np.array(B)
E =np.array([])
E = C - D
x = 0
for i in E:
  if i > 0:
    x = x + i
print(x)

Submission status: Accepted

Solution code:
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(0,n):
    if v[i]>c[i]:
        ans+=v[i]-c[i]
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
V = list(map(int , input().split()))
C = list(map(int , input().split()))
B = 0

for n in range(N):
	if V[n] - C[n] > 0:
		B += V[n] - C[n]

print(B)

Submission status: Accepted

Solution code:
n = int(input())
v = [int(item) for item in input().split()]
c = [int(item) for item in input().split()]

d = [[v[i], c[i]] for i in range(n)]
d.sort(key=lambda x: x[0] - x[1], reverse=True)

ans = 0
i = 0
while i < n and d[i][0] - d[i][1] > 0:
    ans += d[i][0] - d[i][1]
    i += 1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

Vmax = 0
for i in range(N):
    gain = V[i] - C[i]
    if(gain > 0):
        Vmax += gain

print(Vmax)

Submission status: Accepted

Solution code:
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

sum = 0
for i in range(n):
    diff  = v[i] - c[i]
    if diff > 0:
       sum += diff

print (sum)

Submission status: Accepted

Solution code:
in_data = [list(map(int,input().split())) for i in range(3)]

N = in_data[0][0]

earn_ttl = 0

for i in range(N):
    value = in_data[1][i]
    cost = in_data[2][i]
    earn = value - cost
    if (earn > 0):
        earn_ttl = earn_ttl + earn
        
print(earn_ttl)

Submission status: Accepted

Solution code:
N = int(input())
V = list(map(int, input().split(" ")))
C = list(map(int, input().split(" ")))
value = 0
for n in range(N):
    if V[n] - C[n] > 0:
        value += V[n] - C[n]

print(value)

Submission status: Accepted

Solution code:
N = int(input())
V = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

num = 0

for i in range(N):
  if V[i] > C[i]:
    num += V[i] - C[i]

print(num)

Submission status: Accepted

Solution code:
import itertools
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
vc=[]
for i in range(n):
  vc.append(v[i]-c[i])
sv=[]
for L in range(0, len(v)+1):
    for subset in itertools.combinations(vc, L):
      sv.append(sum(subset))
print(max(sv))

Submission status: Accepted

Solution code:
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

z=0

for i in range(N):
    if(V[i] > C[i]):
        z += (V[i]-C[i])
print(z)

Submission status: Accepted

Solution code:

num = int(input())
data_value = list(map(int, input().split()))
data_cost = list(map(int, input().split()))
ans = 0

def ans_check(all_cost):
    global ans
    if ans < all_cost:
        ans = all_cost


def calc_ans(ind, all_cost, in_out_flg):
    if ind == num:
        ans_check(all_cost)
        return
    if in_out_flg:
        all_cost = all_cost + data_value[ind] - data_cost[ind]

    calc_ans(ind + 1, all_cost, 0)
    calc_ans(ind + 1, all_cost, 1)



def main():
    calc_ans(0, 0, 0)
    calc_ans(0, 0, 1)

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))

res = 0
for i in range(N) :
    a = V[i] - C[i]
    if a > 0:
        res = res + a
    else:
        pass

print(res)

Submission status: Accepted

Solution code:
N = map(int, input().split())
values = list(map(int, input().split()))
costs = list(map(int, input().split()))
# N = 3
# values = [10, 2, 5]
# costs = [6, 3, 4]
# N = 4
# values = [13, 21, 6, 19]
# costs = [11, 30, 6, 15]
# N = 1
# values = [1,]
# costs = [50,]


def calculate_maximum_gain(values, costs):
    gain = 0
    for value, cost in zip(values, costs):
        if value - cost > 0:
            gain = gain + value - cost
    
    return gain


print(calculate_maximum_gain(values, costs))

Submission status: Accepted

Solution code:
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
l = []
result = 0
for i in range(n):
    l.append(v[i] - c[i])
for i in l:
    if i > 0:
        result += i
print(result)

Submission status: Accepted

Solution code:
N = input()
VS = [int(i) for i in input().split()]
CS = [int(i) for i in input().split()]

print(sum([a - b for a, b in zip(VS, CS) if a - b > 0]))

Submission status: Accepted

Solution code:
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
li=[]
for i in range (0,n):
  li.append(v[i]-c[i])
t=0
len_li=len(li)
for j in range (0,len_li):
  if li[j]>=0:
    t=t+li[j]
print(t)

Submission status: Accepted

Solution code:
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

count = 0
for i in range(N):
    if int(V[i]) - int(C[i]) > 0:
        count += int(V[i]) - int(C[i])

print(count)

Submission status: Accepted

Solution code:
import numpy as np

n=int(input())
v = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]

v = np.array(v)
c= np.array(c)
hikizan = v-c

x = np.zeros((3,n))
x[1] = v
x[2] = c
x[0] = hikizan

kotae = 0

for i in range(0,n):
    if x[0,i] > 0:
        kotae += x[0,i]
        
print(int(kotae))

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
for i in range(n):
    if a[i]-b[i]>0:
        ans+=a[i]-b[i]
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()] 

C = [A[i] - B[i] for i in range(N) if A[i] - B[i] > 0 ]

print(sum(C))

Submission status: Accepted

Solution code:
N = int(input().rstrip())
V = map(int, input().rstrip().split())
C = map(int, input().rstrip().split())
MAX = 0
for v, c in zip(V, C):
  if v > c:
    MAX += v - c
print(MAX)

Submission status: Accepted

Solution code:
read = input
n = int(read())
V = map(int, read().split())
C = map(int, read().split())
A = list(zip(V,C))
mx = 0
for (v,c) in A:
    if v > c:
        mx += v - c
print(mx)

Submission status: Accepted

Solution code:
a = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split())) 
ans = 0
for i in range(a):
    if v[i] >= c[i]:
        ans += (v[i]-c[i])
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

v = list(map(int, input().split()))
c = list(map(int, input().split()))

dp = [0] * (n + 1)

for i in range(1, n + 1):
    dp[i] = max(dp[i - 1] + v[i - 1] - c[i - 1], dp[i - 1])
print(dp[-1])

Submission status: Accepted

Solution code:
# coding:utf-8
n = int(input())
value = [int(d) for d in input().split(" ")]
cost = [int(d) for d in input().split(" ")]
valueSum = 0
costSum = 0
vcdifList = list()
for i in range(n):
	vc = value[i] - cost[i]
	if vc > 0:
		vcdifList.append(vc)
print(sum(vcdifList))

Submission status: Accepted

Solution code:
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(N):
  diff = V[i] - C[i]
  if diff >= 0:
    ans += diff

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
vl = list(map(int, input().split()))
cl = list(map(int, input().split()))
s = 0

for v,c in zip(vl,cl):
    if(v - c > 0):
     s += v-c
print(s)

Submission status: Accepted

Solution code:
f=lambda:list(map(int,input().split()))
f()
print(sum(max(0,a-b)for a,b in zip(f(),f())))

Submission status: Accepted

Solution code:
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(n):
    if v[i] - c[i] > 0:
        ans += v[i] - c[i]
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8

import sys
input = sys.stdin.readline

N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
# N, K = map(int, input().split())
# S = input()

difv = [V[i] - C[i] for i in range(N)]

ans = 0
for x in difv:
    if x > 0:
        ans += x

print(ans)

Submission status: Accepted

Solution code:
n = input()
v = [int(s) for s in input().split()]
c = [int(s) for s in input().split()]
a = 0
for v_, c_ in zip(v,c):
    if v_>c_:
        a+=v_-c_
print(a)

Submission status: Accepted

Solution code:
N=int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))

ans=0

for i in range(N):
    if V[i]>C[i]:
        ans+=V[i]-C[i]
    elif V[i]<C[i]:
        ans+=0
    else:
        ans+=0

print(ans)

Submission status: Accepted

Solution code:
a = int(input())
N = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
i=0
v=0

for i in range(len(N)):
    if N[i] > C[i]:
        v +=N[i]-C[i]

print(v)