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 = input()
n = int(n)
v = list()
k = 0
l = 0
a = input().split()
for i in range(n):
  p = int(a[k])
  v.append(p)
  k += 1
c = list()
b = input().split()
for i in range(n):
  q = int(b[l])
  c.append(q)
  l += 1
u = 0
count = 0
for i in range(n):
  g = v[count]-c[count]
  count += 1
  if g > 0:
    u += g
print(u)

Submission status: Accepted

Solution code:
#ABC125B
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())
val=[int(s) for s in input().split()]
cost=[int(s) for s in input().split()]
sum=0
for i in range(N):
  d=val[i]-cost[i]
  if d>0:sum+=d
print(sum)

Submission status: Accepted

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

print(max_diff)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin

readline = stdin.readline

n, *vc = map(int, open(0).read().rstrip().split())
res = 0
for v, c in zip(vc[:n], vc[n:]):
    res += max(v - c, 0)

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 index in range(len(V)):
    
    if V[index] > C[index]:
        ans+= V[index] - C[index]
      
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):
  tmp = v[i]-c[i]
  if tmp>0:
    res += tmp
print(res)

Submission status: Accepted

Solution code:
def main():
  if 'get_ipython' not in globals():  
    # For Subsession
    N = int(input())
    V = list(map(int, input().split()))
    C = list(map(int, input().split()))
  else:
    # N = 3
    # V = [10,2,5]
    # C  = [6,3,4]
    # N = 4
    # V = [13,21,6,19]
    # C  = [11,30,6,15]
    N = 1
    V = [1]
    C  = [50]
  i = 0
  ans = 0
  D = []
  for i in range(N):
    tmp = V[i] - C[i]
    if tmp > 0:
      ans += tmp
    
  print(ans)
  
main()

Submission status: Accepted

Solution code:
n = int(input())

v = [int(i) for i in input().split(" ")]
c = [int(i) for i in input().split(" ")]

vc = []
for i in range(n):
  vc.append(v[i] - c[i])
vc.sort(reverse = True)

count = 0
for i in vc:
  if i <= 0 :
    break
  else:
    count += i
print(count)

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ri = 0
for i in range(0,n):
    a  = v[i] - c[i] 
    if a>0:
        ri += a
    else:
        pass
print(ri)

Submission status: Accepted

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

def check(i,cc):
  if i == N:
    return cc
  c1 = check(i+1,cc)
  c2 = check(i+1,cc+(V[i] - C[i]))
  return max(c1,c2)

print(check(0,0))

Submission status: Accepted

Solution code:
N = int(input())
Vl = list(map(int, input().split()))
Cl = list(map(int, input().split()))
a = 0
for i in range(0, N):
  bb = Vl[i] - Cl[i]
  if bb > 0:
    a += bb
print(a)

Submission status: Accepted

Solution code:
n = int(input())
vlist = [int(x) for x in input().split(" ")]
clist = [int(x) for x in input().split(" ")]

result = 0

for i in range(n):
	diff = vlist[i] - clist[i]
	result += diff if diff > 0 else 0
	
print(result)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
import itertools as itr 

n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
maxxy = -10**9
for i2 in itr.product((0,1), repeat = n):
    xy = 0
    for j in range(n):
        if i2[j] == 1:
            xy += v[j]
            xy -= c[j]
    if xy > maxxy:
        maxxy = xy
        #print(s)
print(maxxy)

Submission status: Accepted

Solution code:
n = int(input())
list_v = list(map(int, input().split()))
list_c = list(map(int, input().split()))
print(sum(map(lambda i: 0 if (list_v[i] - list_c[i]) < 0 else (list_v[i] - list_c[i]), range(len(list_v)))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations

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

max_diff = -10000000
for n_selection in range(0, N+1):
    v_selected = list(combinations(v_list, n_selection))
    c_selected = list(combinations(c_list, n_selection))
    if n_selection == 0:
        max_diff = max(max_diff, 0)
    for i in range(len(v_selected)):
        X = sum(v_selected[i])
        Y = sum(c_selected[i])
        max_diff = max(max_diff, X - Y)

print(max_diff)

Submission status: Accepted

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

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

value = 0

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

print(value)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

N=int(input())
V=np.asarray(list(map(int,input().split())))
C=np.asarray(list(map(int,input().split())))

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

Submission status: Accepted

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

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

print(result)

Submission status: Accepted

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

ans = []
def chr(a,l,r):
    global ans
    if a == n:
        ans.append(r-l)
    else:
        chr(a+1,l+c[a],r+v[a])
        chr(a+1,l,r)
chr(0,0,0)
print(max(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,i-j) for i,j in zip(v,c)]))

Submission status: Accepted

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

result = 0

for j in range(n):
    if ( (v[j] - c[j]) > 0):
        result = result + (v[j]-c[j])

print(result)

Submission status: Accepted

Solution code:
# coding: utf-8

intN = int(input())

intValues = list(map(int, input().split()))
intCosts = list(map(int, input().split()))

intTotalValue = 0
for intIdx, intValue in enumerate(intValues):
    intDiff = intValue - intCosts[intIdx]
    if intDiff > 0:
        intTotalValue += intDiff

print(intTotalValue)

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
X = np.array(list(map(int,input().split(' '))))
Y = np.array(list(map(int,input().split(' '))))
Z = X -Y
Z = Z[np.where(Z >= 0)]
print(Z.sum())

Submission status: Accepted

Solution code:
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
x=0
y=0
l=[v[j]-c[j] for j in range(n)]
l.sort(reverse=True)
l=filter(lambda x:x >0,l)
print(sum(l))

Submission status: Accepted

Solution code:
N = int(input())
V_li = list((map(int, input().split())))
C_li = list((map(int, input().split())))

ans_li = []
for i in range(N):
    R = V_li[i] - C_li[i]
    if R >= 0:
        ans_li.append(R)
print(sum(ans_li))

Submission status: Accepted

Solution code:
N = int(input())
C = []
V = []
i = 0
X_Y = 0
for x in input().split():
  x = int(x)
  V.append(x)
for x in input().split():
  x = int(x)
  C.append(x)
  if V[i] > C[i]:
    X_Y = X_Y + V[i] - C[i]
  i = i + 1

print(X_Y)

Submission status: Accepted

Solution code:
n = int(input())
v = input().split(" ")
c = input().split(" ")
plus_list = []

for i in range(n):
    res = int(v[i]) - int(c[i])
    if res > 0:
        plus_list.append(res)

r = len(plus_list)
if r > 0:
    print(sum(plus_list))
else:
    print(0)

Submission status: Accepted

Solution code:
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque
import heapq
import math
import bisect


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())
e = [[int(i) for i in input().split()] for i in range(2)] 
n = len(e[0])
result = 0
for i in range(n):
    if e[0][i] > e[1][i]:
        result = result + (e[0][i] - e[1][i])
        
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

import copy

flag = [0]*N
def dfs(x, y):
    if y==1:
        flag[x] = 1
    else:
        flag[x] = 0
    if x==N-1:
        value = 0
        cost = 0
        for i in range(N):
            if flag[i] == 1:
                value += V[i]
                cost += C[i]
        # print(flag)
        # for i in range(N):
        #     flag[i] = 0
        return value - cost

    
    return max(dfs(x+1, 0),dfs(x+1, 1))

print(dfs(-1,0))

Submission status: Accepted

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

v_c = [v - c for v, c in zip(V, C)]

result = 0
for i in v_c:
  if i > 0:
    result += i
print(result)

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

Submission status: Accepted

Solution code:
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
ALL = []
for i in range(N):
    ALL.append( int(V[i]-C[i]) )
ALL.sort()
ALL.reverse()
AllMax = 0
for i in range(N):
    if i == 0:
        if ALL[0] < 0:
            break
        else:
            AllMax = AllMax+ALL[i]
    elif ALL[i] < 0:
        break
    elif ALL[i] >= 0:
        AllMax = AllMax+ALL[i]
        
print(AllMax)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    V = list(map(int,input().split()))
    C = list(map(int,input().split()))
    cnt=0
    for i in range(len(V)):
        if V[i] < C[i]:
            pass
        else:
            cnt += V[i]-C[i]
    print(cnt)


solve()

Submission status: Accepted

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

      
  print(sum)
    
  
main()

Submission status: Accepted

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

Submission status: Accepted

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

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

profits = []
z = 0

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

#print(profits)
for i in range(n):
    p = profits.pop()
    #print(p)
    if p <= 0:
        print(z)
        exit()
    else:
        z += p
print(z)

Submission status: Accepted

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

XY = []
s = 0
for k in range(N):
    xy = X[k] - Y[k]
    XY.append(xy)

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

print(s)

Submission status: Accepted

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

for i in range(N):
	if V[i] <= C[i]:
		V[i] = 0
		C[i] = 0

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

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

print(all)

Submission status: Accepted

Solution code:
def main():

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

    value = 0

    for n in range(N):
        value += max(0, V[n] - C[n])        

    print(value)

main()

Submission status: Accepted

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

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

Submission status: Accepted

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

G = [v - c for v, c in zip(V, C)]

s = 0
for g in G:
    if g > 0:
        s += g

print(s)

Submission status: Accepted

Solution code:
#0WA n==1 mod saikikilimit exit
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.append(v[i]-c[i])
print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 0
Sub = [a - b for a, b in zip(V_int, C_int)]
for x in Sub:
    if x > 0 :
        ans = ans + x
print(ans)

Submission status: Accepted

Solution code:
num=input()
value=map(int,raw_input().split())
cost=map(int,raw_input().split())

sums=0

for vi,ci in zip(value,cost):
    if vi > ci:
        sums+=(vi-ci)
print sums

Submission status: Accepted

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

print(Z)

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: ans += tmp
print(ans)

Submission status: Accepted

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

i = 0
r = 0
for v in vs:
  if v - cs[i] > 0:
    r += v - cs[i]
  i += 1

print(r)

Submission status: Accepted

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

Submission status: Accepted

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

    sum = 0
    for i in range(0, len(V)):
        tmp = V[i] - C[i]
        if (tmp >= 0):
            sum += tmp

    print(sum)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
V = [int(i) for i in input().split()]
C = [int(i) for i in 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:
A = int(input())

B = input()
w = B.split(' ')

C = input()
x = C.split(' ')

q1 = 0
q2 = 0

for p1, p2 in zip(w, x):
    if int(p1) > int(p2):
        q1 += int(p1)
        q2 += int(p2)
    
print(q1 - q2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
s = [input().split() for i in range(2)]
profit = 0
for j in range(N):
  if int(s[0][j]) - int(s[1][j]) > 0:
    profit += int(s[0][j]) - int(s[1][j])
print(profit)

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
V = np.array([int(i) for i in input().split()])
C = np.array([int(i) for i in input().split()])

score = V-C
score[score < 0] = 0

print(sum(score))

Submission status: Accepted

Solution code:
def a():
    N = raw_input().split(" ")
    A = int(N[0])
    B = int(N[1])
    T = int(N[2])

    print T / A * B

def b():
    sum = 0
    N = int(raw_input())
    V = raw_input().split()
    C = raw_input().split()
    for i in range(N):
        value = int(V[i]) - int(C[i])
        if value > 0:
            sum = sum + value
    print sum
    
def main():
    b()
	
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
values = [int(i) for i in input().split()]
costs = [int(i) for i in input().split()]
differences = []
count = 0
for value in values:
  count += 1
  if value-costs[count-1] > 0:
      differences.append(value-costs[count-1])
print(sum(differences))

Submission status: Accepted

Solution code:
A=int(input())
B=[_ for _ in map(int,input().split())]
C=[_ for _ in map(int,input().split())]
S=0
for i in range(A):
  if B[i]>C[i]:
    S+=B[i]-C[i]
print(S)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3.4
# -*- coding: utf-8 -*-

# abc125_a
import operator

# input
n = int(input())
V = [int(s) for s in input().split()]
C = [int(s) for s in input().split()]
# get ans
D = [v-c for v, c in zip(V, C)]
D = filter(lambda x: x>0, D)
ans = sum(D)
# output
print(ans)

Submission status: Accepted

Solution code:
num = int(input())
values = list(map(int, input().split()))
costs = list(map(int, input().split()))

dp = [0]*(num+1)
for i in range(num):
    diff = values[i] - costs[i]
    dp[i+1] = max( dp[i] + diff, dp[i])
print(dp[num])

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]:
        cost += (V[i] - C[i])

print(cost)

Submission status: Accepted

Solution code:
n = int(input())
# x > yの時、購入。x <= yの時、買わない。購入したら、その差を加えていく。
v = list(map(int, input().split()))
c = list(map(int, input().split()))

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

print(ans)

Submission status: Accepted

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

# process
sV, sC = zip(*sorted(zip(V, C), reverse=True))

maxv = 0
for v, c in zip(sV, sC):
    sabun = v-c
    if sabun < 0:
        continue
    else:
        maxv += sabun
        
print(maxv)

Submission status: Accepted

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

diff = [v - c for v, c in zip(V, C)]

# 差分が大きい順にソート
diff.sort(reverse=True)

ans = 0
max_ = 0
for d in diff:
    ans += d
    if ans > max_:
        max_ = ans 

print(max_)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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=x+v
        y=y+c

print(x-y)

Submission status: Accepted

Solution code:
n=input()

v_n=[]
c_n=[]

sum_n=[]
ans=0
v_n.append(input().split())
c_n.append(input().split())

for i in range(int(n)):
	sum_n.append(int(v_n[0][i])-int(c_n[0][i]))

for i in range(int(n)):
	if sum_n[i] > 0:
		ans += sum_n[i]

print(ans)

Submission status: Accepted

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


a=0
b=0

for _ in range(n):
	if v[_] > c[_]:
		a += v[_]
		b += c[_]
		
print(a-b)

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())))
print(sum([i for i in V-C if i>0]))

Submission status: Accepted

Solution code:
from collections import Counter
from functools import reduce
import bisect
import fractions
import math
import statistics
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):  # Greatest Common Divisor
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):  # Least Common Multiple
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))


n = II()
v = LI()
c = LI()
xy = [v[i] - c[i] for i in range(n)]
print(sum([ xy[i] for i in range(n) if xy[i] > 0]))

Submission status: Accepted

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

vc = []
for i in range(n):
  vc.append(int(v[i]) - int(c[i]))

answer = 0
for i in vc:
  if i > 0:
    answer += i

print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    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)
    return 0

main()

Submission status: Accepted

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

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

print(sum(vc))

Submission status: Accepted

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

b_list = [v - c for (v, c) in zip(v_list, c_list)]
print(sum([b for b in b_list if b > 0]))

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)]
r = 0
for i in range(n):
  if l[i] > 0:
    r += l[i]
print(r)

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

Submission status: Accepted

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

profit = [v[i]-c[i] for i in range(n)]

temp = 0
for i in profit:
  if i>0:
  	temp+=i
print(temp)

Submission status: Accepted

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

sum = 0

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

print(sum)

Submission status: Accepted

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


# Calc profit
#P = []
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:
a = input().split()
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
ans = 0
for i in range(int(a[0])):
  if int(x[i]) - int(y[i]) > 0:
    ans += (int(x[i]) - int(y[i]))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())


V = np.array([int(i) for i in input().split()])


C = np.array([int(j) for j in input().split()])

profit = 0
for k in range(N):
    if V[k] - C[k] > 0:
        profit += V[k] - C[k]
print("{}".format(profit))

Submission status: Accepted

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

n = input()
values = input().split()
costs = input().split()

kekka = 0
for (value, cost) in zip (values,costs):
    rieki = int(value) - int(cost)
    if rieki > 0:
        kekka += rieki

print(kekka)

Submission status: Accepted

Solution code:
juelNum = int(input())
eachValueOrg = input().split()
eachValue = [int(i) for i in eachValueOrg]
eachCostOrg = input().split()
eachCost = [int(i) for i in eachCostOrg]

ans = 0
for i in range(juelNum):
    if eachCost[i] < eachValue[i]:
        ans += (eachValue[i] - eachCost[i])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

A.append(0)
A.sort()
A.reverse()
print(sum(A))

Submission status: Accepted

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

Submission status: Accepted

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

m = 0
o = []

for i in range(n):
  if v[i] - c[i] > 0:
    o.append(v[i] - c[i])

print(sum(o))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
a = 0

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

print(a)

Submission status: Accepted

Solution code:
#ABC125 B
# -*- coding: utf-8 -*-
#N
#a1 a2 a3 ... aN
N = int(input())
V_list = [int(e) for e in input().split()]
C_list = [int(e) for e in input().split()]

ans=0

for i in range(N):
  if V_list[i]-C_list[i] > 0:
    ans=ans+V_list[i]-C_list[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().strip().split(' ')))
c = list(map(int, input().strip().split(' ')))
l = [0] * n
for i in range(n):
  l[i]=v[i]-c[i]
l.sort(reverse=True)
s = 0
for i in range(n):
  if s < sum(l[0:i+1]):
    s = sum(l[0:i+1])
print(s)

Submission status: Accepted

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

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