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:
n = int(input())
a = [i - j for i, j in zip([int(i) for i in input().split()], [int(i) for i in input().split()])]
print(sum(filter(lambda c: c > 0, a)))

Submission status: Accepted

Solution code:
import itertools
import math
import fractions
import functools
import copy
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())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=[]
for i in range(n):
    if v[i]-c[i]>0:
        k=v[i]-c[i]
        ans.append(k)
print(sum(ans))

Submission status: Accepted

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

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n = ii()
    V = lmi()
    C = lmi()
    diff = [V[i] - C[i] for i in range(n)]
    print(sum(filter(lambda x: x>0, diff)))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def q2():
    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] > 0:
            ans += V[i] - C[i]
    return ans

if __name__ == '__main__':
    print(q2())

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    V = list(map(int, input().split()))
    C = list(map(int, input().split()))
    K = [V[i] - C[i] for i in range(N)]
    ans = 0
    for k in K:
        if k > 0:
            ans += k
    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()))
V = []
C = []
for i in range(n):
    if v[i]>c[i]:
        V.append(v[i])
        C.append(c[i])
print(sum(V)-sum(C))

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def bit_count(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#############
# Main Code #
#############

N = inputI()
V = inputIL()
C = inputIL()

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

d.sort()
p = bisect.bisect(d,0)

print(sum(d[p:]))

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):
    Happy = Value[i]-Cost[i]
    if Happy > 0:
        ans += Happy
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()))
xy = 0
for i in range(n):
    if v[i] > c[i]:
        xy += v[i] - c[i]
print(xy)

Submission status: Accepted

Solution code:
import sys
import math
import bisect


def main():
    n = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    for i in range(n):
        A[i] -= B[i]
    ans = 0
    for a in A:
        if a > 0:
            ans += a
    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):
    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]:
        ans += v[i] - c[i]
print(ans)

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(input())
    v = list(map(int, readline().split()))
    c = list(map(int, readline().split()))
    x = [p - q for p, q in zip(v, c)]

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from operator import itemgetter
import sys
sys.setrecursionlimit(1000000)
ans=0

n=int(input())
v=[int(x) for x in input().split()]
c=[int(x) for x in input().split()]
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 = list(map(int,input().split()))
c_list = list(map(int,input().split()))
ans = 0
for i in range(n):
    dum = v_list[i]-c_list[i]
    if dum > 0:
        ans += dum
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

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

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()))
t = []

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n = I()
V = LI()
C = LI()
ans = 0
for i in range(n):
    ans += max(V[i]-C[i], 0)
print(ans)

Submission status: Accepted

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

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

print(out)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    V = list(map(int, input().split()))
    C = list(map(int, input().split()))
    ans = 0
    for i in range(1 << N):
        value = 0
        cost = 0
        for j in range(N):
            if i & (1 << j):
                value += V[j]
                cost += C[j]
        ans = max(ans, value - cost)
    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()))
sum = 0
for i in range(N):
    if V[i] - C[i] > 0:
        sum += V[i] - C[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):
    benefit = V[i] - C[i]
    if benefit > 0:
        ans += benefit

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()]
scores = [V[i] - C[i] for i in range(N)]

ans = 0
for score in scores:
    if score > 0:
        ans += score
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 v, c in zip(V, C):
    diff = v - c
    if diff >= 0:
        ans += diff
print(ans)

Submission status: Accepted

Solution code:
import itertools
import math
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, 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())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
l = [v[i]/c[i] for i in range(n)]
x,y=0,0
for k,i in enumerate(l):
    if i>=1:
        x+=v[k]
        y+=c[k]
print(x-y)

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())
vs = list(map(int, input().split()))
cs = list(map(int, input().split()))

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


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

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())
vs = list(map(int, input().split()))
cs = list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
N=int(input())
Vlist=list(map(int, input().split()))
Clist=list(map(int, input().split()))

ret=0

for i in range(N):
    if Vlist[i]-Clist[i] > 0:
        ret += Vlist[i]-Clist[i]
print(ret)

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 v, c in zip(V, C):
    if v > c:
        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 in range(n):
    if V[i] > C[i]:
        ans += V[i] - C[i]
        
print(ans)

Submission status: Accepted

Solution code:
# ABC125B

n = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
x = 0
y = 0
for v, c in zip(V, C):
    if v > c:
        x += v
        y += c
print(abs(x - y))

Submission status: Accepted

Solution code:
def resale(n, vli, cli):

    ans = 0

    for i in range(len(vli)):
        if vli[i]-cli[i] > 0:
            ans += vli[i]-cli[i]

    return ans

def main():
    n = int(input())
    vli = list(map(int, input().split()))
    cli = list(map(int, input().split()))
    print(resale(n, vli, cli))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
vl=list(map(int,input().split()))
cl=list(map(int,input().split()))
a=0
for v,c in zip(vl,cl):
  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]
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()))
ans = 0
h = 0
while h < n:
  if v[h] >= c[h]:
    ans += v[h] - c[h]
  h += 1
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 c[i] < v[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()))
xy = [0]*n
ans = 0
for i in range(n):
    xy[i] = v[i] - c[i]
    if xy[i] > 0:
        ans += xy[i]
print(ans)

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

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())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
v = 0

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

Submission status: Accepted

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

toku = 0
total = 0

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

Submission status: Accepted

Solution code:
import sys
import math
from collections import Counter
import itertools
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

N=II()
V=LI()
C=LI()

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

arr = [x-y for x,y in zip(v,c)]

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

Submission status: Accepted

Solution code:
n=int(input())
listv=list(map(int,input().split()))
listc=list(map(int,input().split()))
list=[]
for t in range(n):
  if listv[t]-listc[t]>0:
    list.append(listv[t]-listc[t])
print(sum(list))

Submission status: Accepted

Solution code:
N = int(input())

value = list(map(int,input().split()))

cost = list(map(int,input().split()))

sum = 0
for i in range(N) :
    if value[i] >= cost[i] : 
        sum = sum + value[i] - cost[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):
  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):
  if v[i] - c[i] > 0:
    ans += v[i] - c[i]

print(ans)

Submission status: Accepted

Solution code:
max = 0
a = [0]
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
while True:
  if N == 1:
    print("0")
    break
  for i in range(N):
    if V[i] > C[i]:
      a.append(V[i]-C[i])
  for i in a:
    max += i
  print(max)
  break

Submission status: Accepted

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

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

diff = [0]
for n in range(N):
  if V[n] - C[n] > 0:
    diff.append(V[n] - C[n])

print(sum(diff))

Submission status: Accepted

Solution code:
n = int(input())
xlist = list(map(int,input().split()))
ylist = list(map(int,input().split()))

sum = 0
for i in range(n):
  if xlist[i]-ylist[i]>=0:
    sum += xlist[i]-ylist[i]
    
print(sum)

Submission status: Accepted

Solution code:
_ = int(input())
v_list = [int(x) for x in input().split()]
c_list = [int(x) for x in input().split()]
p_list = [v - c for v, c in zip(v_list, c_list) if v - c > 0]
print(sum(p_list))

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:
# B - Resale

n = int(input())
v = list(int(x) for x in input().split())
c = list(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)

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
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().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 = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]


maximum = 0
profit = []
for i in range(len(v)):
    tmp = v[i] - c[i]
    if tmp > 0:
        maximum += tmp
    tmp = 0

print(maximum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
res = 0
for i in range(n):
  if a[i] > b[i]:
    res += a[i] - b[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 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 n in range(N):
    if V[n]-C[n] > 0:
        total += V[n]-C[n]
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):
    x = v[i] - c[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()))
val=0
for i in range(n):
  xy=v[i]-c[i]
  if xy>0:
    val=val+xy
print(val)

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):
  a=V[i]-C[i]
  if a>0:
    ans+=a
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())
vlist = list(map(int, input().split()))
clist = list(map(int, input().split()))
indi = [v - c for v, c in zip(vlist, clist)]
ans = 0
for i in indi:
    if i > 0:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
V = LIST()
C = LIST()

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

sm = list()
for a, b in zip(V, C):
    sm.append(a-b)

ans = 0

for a in sm:
    if a > 0:
        ans += a

print(ans)

Submission status: Accepted

Solution code:
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)]
ans = 0
for i in range(n):
    if d[i] >= 0:
        ans += d[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):
    profit = v[i] - c[i]
    if 0 < profit:
        ans += profit
    else:
        continue

print(ans)

Submission status: Accepted

Solution code:
# ABC 125: B – Resale
N = int(input())
V = [int(s) for s in input().split()]
C = [int(s) for s in input().split()]

profits = [x - y for x, y in zip(V, C)]
print(sum([k for k in profits if k >= 0]))

Submission status: Accepted

Solution code:
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
xy = [x-y for (x,y) in zip(v,c)]
sm = 0
for x in xy:
    sm = sm+x if x>0 else sm+0
print(sm)

Submission status: Accepted

Solution code:
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
xy = [x-y for (x,y) in zip(v,c)]
sm = 0
for x in xy:
    if x>0:
        sm += x
print(sm)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
icase=0
if icase==0:
    n=int(input())
    v=list(map(int,input().split()))
    c=list(map(int,input().split()))
    tmax=0
    for i in range(n):
        total = 0
        for j in range(n):
            total = total+max(0,v[j]-c[j])   
        tmax=max(tmax,total)
    print(tmax)

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

Submission status: Accepted

Solution code:
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7


def main():
  N = int(readline())
  V = np.array(readline().split(), np.int64)
  C = np.array(readline().split(), np.int64)
  D = V-C
  E = np.where(D<0,0,D)
  print(E.sum())
  
  
  
  
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
import sys


def solve(i, x, y):
    if i == N:
        global max_ans
        max_ans = max(max_ans, x-y)
        return
    solve(i+1, x, y)
    solve(i+1, x+V[i], y+C[i])


sys.setrecursionlimit(2**20)
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
max_ans = 0
solve(0, 0, 0)
print(max_ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    v = [int(a) for a in input().split()]
    c = [int(a) for a in input().split()]
    ds = 0
    for i in range(N):
        d = v[i] - c[i]
        if d > 0:
            ds += d
    print(ds)
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):
    if v[i] > c[i]:
        ans += v[i] - c[i]
print(ans)