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:
# abc125_b.py
# https://atcoder.jp/contests/abc125/tasks/abc125_b

# B - Resale /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# N個の宝石があり、i 番目の宝石の価値は Viです。
# あなたはこれらの宝石の中からいくつかを選んで手に入れます。
# このとき、1つも選ばなくとも、全て選んでも構いません。
# ただし、i番目の宝石を手に入れる場合コスト Ciを支払わなければいけません。
# 手に入れた宝石の価値の合計を X、支払ったコストの合計を Yとします。
# X−Yの最大値を求めてください。

# 制約
#     入力は全て整数である。
#     1≤N≤20
#     1≤Ci,Vi≤50

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N
# V1 V2 ... VN
# C1 C2 ... CN

# 出力
# X−Yの最大値を出力せよ。

# 入力例 1
# 3
# 10 2 5
# 6 3 4

# 出力例 1
# 5

# 1番目の宝石と 3 番目の宝石を選んだとき、X=10+5=15,Y=6+4=10 です。 このとき、X−Y=5となり、これが最大です。

# 入力例 2
# 4
# 13 21 6 19
# 11 30 6 15

# 出力例 2
# 6

# 入力例 3
# 1
# 1
# 50

# 出力例 3
# 0


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # line = lines[0]
    N = int(lines[0])
    # A, B, T = list(map(int, lines[0].split()))
    values_v = list(map(int, lines[1].split()))
    values_c = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(6):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(Q):
    #     valueses.append(list(map(int, lines[i+1].split())))

    result = 0

    for i in range(N):
        dif = values_v[i] - values_c[i]
        if dif > 0:
            result += dif

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['3', '10 2 5', '6 3 4']
        lines_export = [5]
    if pattern == 2:
        lines_input = ['4', '13 21 6 19', '11 30 6 15']
        lines_export = [6]
    if pattern == 3:
        lines_input = ['1', '1', '50']
        lines_export = [0]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(3)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Accepted

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


sum = 0
for xi in range(n):
    if w[xi]>c[xi]:
        sum += w[xi]-c[xi]
print(sum)

Submission status: Accepted

Solution code:
N = int(input())

Vn = list(map(int, input().split()))
Cn = list(map(int, input().split()))


result = 0
temp = 0
for V, C in zip(Vn, Cn):
    temp = V - C
    if temp >= 0:
        result += temp

print(result)

Submission status: Accepted

Solution code:
import sys
import math


def input():
    return sys.stdin.readline().rstrip()


def main():
    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)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N=int(input())
V=list(map(int, input().split()))
C=list(map(int, input().split()))
x=sum(filter(lambda x:x > 0, map(lambda x:x[0]-x[1], zip(V,C))))
print(x)

Submission status: Accepted

Solution code:
n = input()
v = input().split()
c = input().split()
sum = 0
for v1 , c1 in zip(v , c):
  if int(v1) - int(c1) > 0:
    sum += int(v1) - int(c1)
print(sum)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    V = LI()
    C = LI()
    ans = 0
    for i in range(N):
        ans += max(V[i] - C[i], 0)
    print(ans)



main()

Submission status: Accepted

Solution code:
N = int(input())
ListV = list(map(int, input().split()))
ListC = list(map(int, input().split()))
Sum = []
for i in range(N):
  Sum.append(ListV[i]-ListC[i])
res = 0
for i in range(N):
  if Sum[i] > 0:
    res += Sum[i]
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, j in zip(v, c):
    if i >= j:
        ans += i - j

print(ans)

Submission status: Accepted

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

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.append(v[i] - c[i])
  
print(sum(x))

Submission status: Accepted

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

res = 0
for x, y in zip(v, c):
    if (z := x - y) > 0:
        res += z
print(res)

Submission status: Accepted

Solution code:
n=int(input())
v=[*map(int,input().split())]
c=[*map(int,input().split())]
print(sum(max(x-y,0) for x,y in zip(v,c)))

Submission status: Accepted

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

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

print(profit)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

v = list(map(int,input().split()))
c = list(map(int,input().split()))
l =[]
l_max = 0

for i in range(n):
    l.append(v[i]-c[i])
#print(sorted(l,reverse = True))

for i in l:
    if l_max < l_max+i:
        l_max += i

print(l_max)

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:
def main():
  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]>0:
      ans+=v[i]-c[i]
  print(ans)
main()

Submission status: Accepted

Solution code:
input()
(*V,) = map(int, input().split())
(*C,) = map(int, input().split())
print(sum(v - c for (v, c) in zip(V, C) if v - c > 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):
  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()))
d = sorted([v[i]-c[i] for i in range(len(v))])
sum = 0
for i in d[::-1]:
  if sum+i >= sum:
    sum += 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 v,c in zip(V,C):
  if v>c:
    ans+=(v-c)

print(ans)

Submission status: Accepted

Solution code:
input()
print(sum([max(int(v)-int(c),0) for v,c in zip(input().split(),input().split())]))

Submission status: Accepted

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


resolve()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

def solve(n,v,c):
  l = [v[i] -c[i] for i in range(n)]
  l = filter(lambda x: x >=0,l)
  return sum(l)



def main():
  N = int(input())
  V = list(map(int,input().split()))
  C = list(map(int,input().split()))
  print(solve(N,V,C))
  return

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
list = [0]
x, y = 0, 0

for i in range(len(v)):
    if v[i] > c[i]:
        x += int(v[i])
        y += int(c[i])
        list.append(x - y)
    else:
        continue

print(max(list))

Submission status: Accepted

Solution code:
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
list = [0]
x, y = 0, 0

v_sort = sorted(v,reverse = True)
c_sort = sorted(c,reverse = True)

for i in range(len(v)):
    if v[i] > c[i]:
        x += int(v[i])
        y += int(c[i])
        list.append(x - y)
    else:
        continue

print(max(list))

Submission status: Accepted

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

for (p,q) in zip(x,y):
  if p-q>0:
    ans+=p-q
print(ans)

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 = [v[i]- c[i] for i in range(n)]
ans = sum(x[i] if x[i] > 0 else 0 for i in range(n))
print(ans)

Submission status: Accepted

Solution code:
import sys
N = int(input())
array_value = list(map(int,input().split()))
array_cost = list(map(int,input().split()))

if not ( 1 <= N <= 20 ): sys.exit()
for I in array_value:
    if not ( 1 <= I <= 50 ): sys.exit()
for J in array_cost:
    if not ( 1 <= J <= 50 ): sys.exit()

value_check = 0
for K in range(len(array_value)):
    value = array_value[K] - array_cost[K]
    value_check += value if value >= 1 else 0

print(value_check)

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()))

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:
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
n = int(input())
value = list( map( int, input().split() ) )
cost = list( map( int, input().split() ) )

ans = 0
for i in range(n):
    x = value[i]-cost[i]
    if x > 0:
        ans += x
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 vv, cc in zip(v, c):
    if vv-cc>0:
        ans += vv-cc
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin,stdout

if __name__=="__main__":
    n=int(stdin.readline())

    a=[int(x) for x in stdin.readline().split()]
    b=[int(x) for x in stdin.readline().split()]

    sm=0

    for i in range(n):
        if(a[i]>b[i]):
            sm+=a[i]-b[i]

    stdout.write(str(sm)+"\n")

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    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)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import numpy as np
input = sys.stdin.readline

n=int(input())
v=np.array(list(map(int,input().split())))
c=np.array(list(map(int,input().split())))
s = (v-c)
ans =0
for ss in s:
    ans += ss*(ss>0)
print(ans)

Submission status: Accepted

Solution code:
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
V = LI()
C = LI()

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

print(ans)

Submission status: Accepted

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

ans = 0
for i, j in zip(V,C):
  if i - j > 0:
    ans += i - j
print(ans)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7
_ = ri()
a = rl()
b = rl()
ans = 0
for i, j in zip(a, b):
  ans += max(0, i-j)
print(ans)

Submission status: Accepted

Solution code:
N = input()
V = [int(X) for X in input().split()]
C = [int(X) for X in input().split()]
print(sum(X-Y if X-Y>0 else 0 for X,Y in zip(V,C)))

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    V = map(int, input().split())
    C = map(int, input().split())
    ans = 0
    for v, c in zip(V, C):
        if v - c > 0:
            ans += v - c
    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()))
w = 0
d = 0

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

print(w - d)

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):
    r = v[i] - c[i]
    if r > 0:
        ans += r
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

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

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

print(sum(sa))

Submission status: Accepted

Solution code:
n = int(input())
vn = [int(num) for num in input().split()]
cn = [int(num) for num in input().split()]

answer = 0
for i in range(n):
  if (vn[i] - cn[i]) > 0:
    answer += vn[i] - cn[i]
    
print(answer)

Submission status: Accepted

Solution code:
n,a=int(input()),0
V=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=[0 for _ in range(n)]

for i in range(n):
  ans = V[i] - C[i]
  if ans > 0:
    a += ans
  
print(a)

Submission status: Accepted

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

Submission status: Accepted

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

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):
    cost=v[i]-c[i]
    if cost >0:res+=cost
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]>0:
    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()))

total = 0
for x, y in zip(V, C):
    if x - y > 0:
        total += x - y
print(total)

Submission status: Accepted

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

z = []
for i in range(n):
  z.append(v[i]-c[i])
#print(z)
ans = 0
for i in z:
  if i >= 0:
    ans += i

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]
    else:
        continue
print(ans)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    vlis = list(map(int, input().split()))
    clis = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        value = vlis[i] - clis[i]
        if value > 0:
            ans += value
    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()))

ans = 0

for i in range(N):
    ans += max(0, 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()))
l = []
for x, y in zip(v, c):
    l.append(x-y)
ans = 0
for num in l:
    if num > 0:
        ans += num
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):
    k= v[i]-c[i]
    if k>0:
        ans+=k
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
print(sum(max(0,v-c) for v,c in zip(V,C)))

Submission status: Accepted

Solution code:
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
print(sum(v-c for v,c in zip(V,C) if c<v))

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()))
ans = 0
for i in range(n):
  ans += max(0,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()))
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:
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n):
    ans += max(0, 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()))
res = 0
for i in range(n):
  res += max(0, v[i] - c[i])
print(res)

Submission status: Accepted

Solution code:
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
A = [v-c for v, c in zip(V, C) if v-c > 0]
print(sum(A))

Submission status: Accepted

Solution code:
#create date: 2020-06-29 13:18

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    v = na()
    c = na()
    ans = 0
    for vi, ci in zip(v, c):
        ans += max(0, vi-ci)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
a = np.array(v)
b = np.array(c)
c = a - b
c1 =c.tolist()
c2 = sorted(c1)
ans = 0
for i in c2:
    if(i >= 0):
        ans += i
print(ans)

Submission status: Accepted

Solution code:
import sys
# from math import sqrt, gcd, ceil, log
from bisect import bisect
from collections import defaultdict, Counter
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)



def solve():
	n = int(inp()); a = read(); b = read()
	ans = 0
	for i in range(n):
		ans += max(0, a[i]-b[i])
	print(ans)

	





		

if __name__ == "__main__":
	solve()

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()))
value=[]
for i in range(n):
    value.append(v[i]-c[i])
ans=0
for i in range(len(value)):
    if value[i]>0:
        ans+=value[i]
print(ans)

Submission status: Accepted

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

ans = []
for i in range(N):
  if V[i]-C[i] > 0:
    ans.append(V[i]-C[i])
print(sum(ans))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)

n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

ans = 0

for i,j in zip(v,c):
    if i > j:
        ans += i-j
        
print(ans)

Submission status: Accepted

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

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

print(answer)

Submission status: Accepted

Solution code:
n = int(input())
v = [int(k) for k in input().split()]
c = [int(k) for k in input().split()]
ans = 0
for i in range(n):
  a = v[i]-c[i]
  if a > 0:
    ans += a
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()]
ans=0
for v,c in zip(V,C):
    if v-c>0:
        ans+=v-c
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()]
ans=0
for i in range(N):
    ans+=max(0,V[i]-C[i])
print(ans)

Submission status: Accepted

Solution code:
from itertools import product as p

N = int(input())
*V, = map(int, input().split())
*C, = map(int, input().split())

ans = -10**12
for i in p(range(2), repeat=N):
    X, Y = 0, 0
    for j, k in enumerate(i):
        if k==1:
            X += V[j]
            Y += C[j]
    ans = max(ans, X-Y)
print(ans)

Submission status: Accepted

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

P = [v-c for v, c in zip(V, C)]
P_plus = [p if p > 0 else 0 for p in P]
print(sum(P_plus))

Submission status: Accepted

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

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())))
ans = V - C

print(sum([i for i in ans if i >= 0]))

Submission status: Accepted

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    V = il()
    C = il()
    ret = 0
    for v, c in zip(V, C):
        ret = max(ret, ret + v - c)
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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 += max(0,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()))
cnt=0
for i in range(n):
  if v[i]-c[i]>0:
    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()))

W = [V[i]-C[i] for i in range(0,N,1)]

ans =0

for i in range(0,N,1):
    if W[i]>0:
        ans += W[i]
print(ans)

Submission status: Accepted

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

ans=0

for i in range(n):
    if b[i]>c[i]:
        ans+=(b[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()))
result = 0

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

Submission status: Accepted

Solution code:
input()
v=list(map(int,input().split()))
c=list(map(int,input().split()))
a=[max(0,i-j) for i,j in zip(v,c)]
print(sum(a))

Submission status: Accepted

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

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

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

for j in range(N):
	if sub[j] > 0:
		ans += sub[j]
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()]
m = 0
for i in range(N):
  if (V[i]-C[i]) > 0:
    m = m + V[i]-C[i]
print(m)

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):
  z = v[i] - c[i]
  ans = max(ans, ans+z)
print(ans)

Submission status: Accepted

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

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 = raw_input()
vis = map(int, raw_input().split(' '))
cis = map(int, raw_input().split(' '))
r= 0
for c,v in zip(cis, vis):
  r += max(0,v - c)
print r

Submission status: Accepted

Solution code:
def solve():
    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)


if __name__ == '__main__':
    solve()

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:
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
m=[v[i]-c[i] for i in range(n) if v[i]>c[i]]
print(sum(m))

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:
def main():
    n=int(input())
    v=list(map(int,input().split()))
    c=list(map(int,input().split()))
    d=[v[i] - c[i] for i in range(n)]
    print(sum((x for x in d if x > 0)))
    
if __name__ == "__main__":
    main()

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]
    if tmp<=0:
        continue
    else:
        ans+=tmp
print(ans)