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 importlib
import_module = lambda name:importlib.import_module(name)

input = import_module('sys').stdin.readline
input_int = lambda:int(input())
input_ints = lambda:map(int,input().split())
input_ints_list = lambda:list(input_ints())
input_str = lambda:input()
input_strs = lambda:input().split()
input_lines = lambda n,f:[f() for _ in range(n)]

gcd_base = lambda a,b:import_module('fractions').gcd(a,b) # 最大公約数（2値)
gcd = lambda a:import_module('functools').reduce(gcd_base,a) # 最大公約数（リスト）
lcm_base = lambda a,b:(a*b)//import_module('fractions').gcd(a,b) # 最小公倍数(2値)
lcm = lambda a:import_module('functools').reduce(lcm_base,a,1) # 最小公倍数(リスト)

permutations = lambda a,n:import_module('itertools').permutations(a,n) # 順列
combinations = lambda a,n:import_module('itertools').combinations(a,n) # 組み合わせ
product = lambda a,b:import_module('itertools').product(a,b) # 二つのリストの直積

init_array_1dim = lambda v,n:[v]*n
init_array_2dim = lambda v,n,m:[init_array_1dim for _ in range(m)]

# 四捨五入はround
ceil = lambda a:import_module('math').ceil(a) # 切り上げ
floor = lambda a:import_module('math').floor(a) # 切り捨て

# キュー
convert_list_to_queue = lambda a:import_module('collections').deque(a)
pop_q = lambda a:a.popleft()
push_q = lambda a,e:a.appendleft(e)
push_q_list = lambda a,l:a.extendleft(l) 

# プライオリティキュー
def init_head(a):import_module('heapq').heapify(a)
def heap_push(a,v):import_module('heapq').heappush(a,v)
heap_pop = lambda a:import_module('heapq').heappop(a) # 最小値を取り出す

# 二分探索
bisect_left = lambda a,x:import_module('bisect').bisect_left(a,x)
bisect_right = lambda a,x:import_module('bisect').bisect_left(a,x)
insert_left = lambda a,x:import_module('bisect').insert_left(a,bisect_left(a,x))
insert_right = lambda a,x:import_module('bisect').insert_right(a,bisect_right(a,x))

# 累積和、累積積、累積GCD
cumsum = lambda a:import_module('numpy').cumsum(import_module('numpy').array(a)) # 累積和
cumprod = lambda a:import_module('numpy').cumprod(import_module('numpy').array(a)) # 累積積
cumgcd = lambda a:import_module('numpy').frompyfunc(gcd, 2, 1).accumulate(a, dtype=import_module('numpy').object).astype(import_module('numpy').int) # 累積GCD

class UnionFind(object):
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        x = self.find(x)
        return self.size[x]

# グラフで全部到達できる経路が何個あるか
def dfs_graph(v,n,graph,visited):
    if all(visited):return 1 # 全部到達できたら1を返す
    ans = 0
    for i in range(n):
        if not graph[v][i]:continue # 結ぶ線がないときはスキップ
        if visited[i]:continue # 到達済みだったらスキップ
        visited[i] = True
        ans += dfs_graph(i,n,graph,visited)
        visited[i] = False
    return ans

# ワーシャルフロイド（グラフの要素数、グラフ）
def warshall_floyd(n,graph):
    d = init_array_2dim(float("inf"),n,n)
    # 初期化
    for i in range(n):
        d[i][i] = 0
        for j in range(n):
            if graph[i][j]:d[i][j] = 1
    # 距離算出
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

# グラフを初期化（グラフの要素数、グラフの線の両端、有向無向）
def init_graph(n,a,directed=False):
    visited = init_array_1dim(False,n)
    graph = init_array_2dim(False,n,n)
    for e in a:
        graph[e[0]-1][e[1]-1] = True
        if not directed:graph[e[1]-1][e[0]-1] = True # 無向グラフの場合
    return visited,graph

def two_pointers(s,threshold,ope='sum'):
    l,r = 0,0
    base = 0 
    if ope == 'sum':base = 0
    if ope == 'prd':base = 1
    diff = 0
    while r < len(s):
        val = 0
        if ope == 'sum':val = base+s[r]
        if ope == 'prd':val = base*s[r]
        if val <= threshold:
            if ope == 'sum':base += s[r]
            if ope == 'prd':base *= s[r]
            diff = max(diff, r-l+1)
            r += 1
        elif l == r:
            r += 1
            l += 1
        else:
            if ope == 'sum':base -= s[l]
            if ope == 'prd':base //= s[l]
            l += 1
    return diff

def solution():
    # ここに実装
    global N,V,C
    N = input_int()
    V = input_ints_list()
    C = input_ints_list()

    vals = [x-y for x,y in zip(V,C) if x-y > 0]
    print(sum(vals))
        
	
if __name__ == '__main__':
    solution()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
v_tuple = tuple(map(int, input().split()))
c_tuple = tuple(map(int, input().split()))
diff_vc = (v_tuple[i] - c_tuple[i] for i in range(n))
print(sum([x for x in diff_vc if x > 0]))

Submission status: Accepted

Solution code:
N=int(input())
vl=input().split()
cl=input().split()
pl = 0
for i in range(N):
    if int(vl[i]) > int(cl[i]):
        pl += int(vl[i]) - int(cl[i])
print(pl)

Submission status: Accepted

Solution code:
N = int(input())
value = [int(i) for i in input().split(" ")]
cost = [int(i) for i in input().split(" ")]
total = 0
for i in range(N):
  if (value[i] - cost[i]) > 0:
    total += (value[i] - cost[i])

print(total)

Submission status: Accepted

Solution code:
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
tv = []
ans = 0
for i in range(n):
    tv.append(v[i] - c[i])
tv.sort()
tv = reversed(tv)
for i in tv:
    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]
print(ans)

Submission status: Accepted

Solution code:
def calc_max_total_jewels_value():
  jewels = int(input())
  jewel_value = [int(x) for x in input().split()]
  jewel_cost = [int(x) for x in input().split()]
  
  max_total_jewels_value = 0
  for jewel_no in range(jewels):
    max_total_jewels_value += max([0, jewel_value[jewel_no] - jewel_cost[jewel_no]])
    
  return max_total_jewels_value

if __name__ == '__main__':
  print(calc_max_total_jewels_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 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 i in range(N):
  if v[i] - c[i] > 0:
    total += v[i] - c[i]
    
print(total)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
def main():
  size = int(input())
  value = list(map(int, input().split()))
  cost = list(map(int, input().split()))
  diff = [value[i]-cost[i] for i in range(len(value))]
  diff.sort(reverse=True)
              
  sum = 0
  for i in range(len(value)):
    if diff[i] > 0:
      sum += diff[i]
    else: 
      break
        
  print(sum)

main()

Submission status: Accepted

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

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

    value = V[i] - C[i]

    if(value > 0):
        ans += value

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) if v-c > 0]
print(sum(P))

Submission status: Accepted

Solution code:
n = int(input())
gem_value = list(map(int, input().split(' ')))
gem_cost = list(map(int, input().split(' ')))
max_value = 0

for i in range(n):
  if gem_value[i] > gem_cost[i]:
    max_value += gem_value[i] - gem_cost[i]

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
goukei=0

Vn=input().rstrip().split(" ")
Cn = input().rstrip().split(" ")

for i in range(N):
  dif = int(Vn[i]) - int(Cn[i])
  if dif > 0:
    goukei += dif
print(goukei)

Submission status: Accepted

Solution code:
N = int(input())
Value_list = [int(x) for x in input().split()]
Cost_list = [int(x) for x in input().split()]
diff_sum = 0

for i in range(N):
    
    difference = Value_list[i] - Cost_list[i]
    
    if difference < 0:
        pass
    else:
        diff_sum += difference

print(diff_sum)

Submission status: Accepted

Solution code:
#入力回数の取得
n = int(input())
#複数行の数値の取得
v = input().split()
c = input().split()
sum=0

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

Submission status: Accepted

Solution code:
N = int(input())
values = list(map(int, input().split()))
costs = list(map(int, input().split()))
s = 0
for v, c in zip(values, costs):
    if v - c > 0:
        s += v - c
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
varr = list(map(int,input().split()))
carr = list(map(int,input().split()))

ans = 0

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

temp = lambda x,y: x - y if x > y else 0
print(sum(list(map(temp,v,c))))

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):
    y = v[i] - c[i]
    if y > 0:
        x += y

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())
ans = 0
lst_v = list(map(int,input().split()))
lst_c = list(map(int,input().split()))
for i in range(n):
  if lst_v[i] > lst_c[i]:
    ans += (lst_v[i] - lst_c[i])
  else:
    continue

print(ans)

Submission status: Accepted

Solution code:

n = int(input())

# いくつあるかわからないときのスペース区切りの整数の入力
v = input().split()
v = list(map(int,v))

# いくつあるかわからないときのスペース区切りの整数の入力
c = input().split()
c = list(map(int,c))

k = [0] * n

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

#print(k)
k.sort(reverse=True)
#print(k)

for i in range(0,n):
    if k[i] < 0:
        k[i] = 0

print(sum(k))

Submission status: Accepted

Solution code:
times = int(input())
n = []
for i in range(2):
	n.append(list(map(int, input().split()))) 
    
answer = 0
for j in range(times):
  if (n[0][j] - n[1][j]) > 0:
    answer += (n[0][j] - n[1][j])

print(answer)

Submission status: Accepted

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

max_score=0

for valu,cost in zip(V,C):
  if(valu>cost):
    max_score+=(valu-cost)
print(max_score)

Submission status: Accepted

Solution code:
N = int(input())

Vls = input().split(" ")

V = []

for i in range(0,len(Vls)):
    V.append(int(Vls[i]))

Cls = input().split(" ")

C = []

for i in range(0,len(Cls)):
    C.append(int(Cls[i]))


Max = 0

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

print(Max)

Submission status: Accepted

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

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

Submission status: Accepted

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

diff = map(lambda x, y: x - y, v_list, c_list)
print(sum(filter(lambda x: x > 0, diff)))

Submission status: Accepted

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

print(sum)

Submission status: Accepted

Solution code:
N = int(input())
V = [int(s) for s in input().split() if s.isdigit()]
C = [int(s) for s in input().split() if s.isdigit()]
VC = [int(i - j) for i, j in zip(V, C)]

dp = [0 for _ in range(N+1)]
for i in range(N):
    dp[i+1] = max(dp[i], dp[i] + VC[i])
print(dp[N])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def calculate_max(Ans, value):
    temp = Ans
    if (Ans + value) > Ans:
        temp += value
    if temp < 0 :
        temp = 0
    return temp
# input processing 
N = int(input())
Value = list(map(int, input().split()))
Cost = list(map(int, input().split()))
# profit calculation
Profit = [Value[i] - Cost[i] for i in range(N)]
Answer = 0
# process
for i in range(N):
    Answer = calculate_max(Answer, Profit[i])
# Output
print(Answer)

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
V_list = np.array(list(map(int, input().split())))
C_list = np.array(list(map(int, input().split())))

diff = V_list - C_list

print(diff[diff > 0].sum())

Submission status: Accepted

Solution code:
N = int(input())
W = list(map(int, input().split()))
C = list(map(int, input().split()))
#print(N)
#print(W)
#print(C)

from numpy import *
Z = list(array(W)-array(C))
#print(Z)
x = 0
idx = 0
while idx < len(Z):
    if Z[idx] >= 0:
        x += Z[idx]
        idx += 1
    else:
        idx += 1
print(x)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
va = input().split()
co = input().split()

val = [int(v) for v in va]
cos = [int(c) for c in co]

dif = [val[i]-cos[i] for i in range(n)]
ma = 0
for d in dif:
    ma += d if d >= 0 else 0
print(ma)

Submission status: Accepted

Solution code:
n = int(input())
vs = [int(v) for v in input().split()]
cs = [int(c) for c in input().split()]
sum = 0
for i in range(n):
  if vs[i] - cs[i] > 0:
    sum += vs[i] - cs[i]

print(sum)

Submission status: Accepted

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

n = int(input())
value = [int(s) for s in input().split()]
cost = [int(t) for t in input().split()]

VnS = []

for i in range(n):
    if value[i]-cost[i] > 0:
        VnS.append(value[i] - cost[i])

VnS.sort(reverse=True)
print(sum(VnS))

Submission status: Accepted

Solution code:
n = int(input())

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

sa = [0]*n

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline
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()))

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()))
h=[v[i]-c[i] for i in range(n)]
s=0
for j in range(n):
      if h[j]>0:
            s=s+h[j]
print(s)

Submission status: Accepted

Solution code:

import numpy as np

N=int(input())
V=np.array([int(c) for c in input().split()])
C=np.array([int(c) for c in input().split()])
D=V-C
print(np.sum(D[D>0]))

Submission status: Accepted

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

cost = 0

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

Submission status: Accepted

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

print(sum([ v - c for v, c in zip(Vs, Cs) if v >= c ]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

optCost = 0
for i in range(N):
    if diff[i]>0:
        optCost+=diff[i]
print(optCost)

Submission status: Accepted

Solution code:
N = int(input())
v_list = [int(x) for x in input().split()]
c_list = [int(x) for x in input().split()]
p_list = [x-y for x, y in zip(v_list, c_list)]

ans = 0
for i in p_list:
    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()))
sum = 0
for i in range(N):
    sum += max(0, V[i]-C[i])
print(sum)

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 = []
sum = 0

for i in range(len(a)):
  if a[i]-b[i] > 0:
    c.append(a[i]-b[i])
  else:
    continue
    

for i in range(len(c)):
  sum = sum + c[i]
  
print(sum)

Submission status: Accepted

Solution code:
N = int(input())
V = input().split()
C = input().split()
Z = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(n, v, c):
    res = 0
    for i in range(n):
        res += max(0, v[i] - c[i])
    return res

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

Submission status: Accepted

Solution code:
N = input()
V_list = list(map(int,input().split()))
C_list = list(map(int,input().split()))
result = 0
counter = 0
for i in V_list:
  if i > C_list[counter]:
    result = i-C_list[counter]+result
  counter += 1
  
print(result)

Submission status: Accepted

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

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

print(cost)

Submission status: Accepted

Solution code:
N = int(input())
V = input()
C = input()

Vs = [V.split()[i] for i in range(0, N)]
Cs = [C.split()[i] for i in range(0, N)]

sum = 0
for v_i, c_i in zip(Vs, Cs):
  sub = int(v_i) - int(c_i)
  if sub > 0:
    sum += sub

print(sum)

Submission status: Accepted

Solution code:
def solve():
    N = int(raw_input())
    V = [int(_) for _ in raw_input().split()]
    C = [int(_) for _ in raw_input().split()]
    get = [V[i] - C[i] for i in range(N)]
    sum = 0
    for i in range(N):
        if get[i] > 0:
            sum += get[i]
    print str(sum)

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
N = int(input())
V = list(map(int, input().split()))
C = list(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(map(int, input().split()))

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

P = 0

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

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