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: Runtime Error

Solution code:
in_data = [list(map(int,input().split())) for i in range(3)]
print(ls)
print(in_data[0])
print(in_data[1])
print(in_data[2])
print("--------")

N = in_data[0][0]

earn_ttl = 0

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

Submission status: Runtime Error

Solution code:
N = int(input())
listV = map(int, input().split())
listC = map(int, input().split())
//listP P:Profit = listV(i) - listC(i)
ans = 0
for i in range(0, N):
	P = listV[i] - listC[i]
	if P > 0:
		ans += P
//if sum < 0, ans = 0.
//how can I search combination of sum. -> sum all listP(i) > 0
print(ans)

Submission status: Runtime Error

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


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


print(calculate_maximum_gain(values, costs))

Submission status: Runtime Error

Solution code:
N = input()
a = [input() for i in range(N)]
b = [input() for i in range(N)]

sum = 0

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

print(sum)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
v = input().split()
c = 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: Runtime Error

Solution code:
N = int(input())
listV = map(int, input().split())
listC = map(int, input().split())
//listP P:Profit = listV(i) - listC(i)
ans = 0
for(i = 0; i < N; i++):
	P = listV[i] - listC[i]
	if(P > 0):
		ans += P
//if sum < 0, ans = 0.
//how can I search combination of sum. -> sum all listP(i) > 0
print(ans)

Submission status: Runtime Error

Solution code:
X = [0 for i in range(2**N)]
Y = [0 for i in range(2**N)]
Z = [0 for i in range(2**N)]

for i in range(2**N):
    select = []
    if i > 0:
        temp = i
        for n in reversed(range(1, N+1)):
            if temp - 2**(n-1) >= 0:
                temp = temp - 2**(n-1)
                select.append(n-1)
            else:
                pass
        X[i] = sum([V[i] for i in select])
        Y[i] = sum([C[i] for i in select])
        Z[i] = X[i] - Y[i]
print(max(Z))

Submission status: Runtime Error

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

for i in range(a):
    if v(i) >= c(i):
        ans += (v(i)-c(i))
        
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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 < C:
            pass
        else:
            cnt += V(i)-C(i)
    print(cnt)


solve()

Submission status: Runtime Error

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: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
v = map(int, input().split())
c = 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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
v = [int(input()) for _ in range(n)]
c = [int(input()) for _ in range(n)]

a=0
b=0

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

Submission status: Runtime Error

Solution code:
 = 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: Runtime Error

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

Submission status: Runtime Error

Solution code:
num = int(input())
value = map (int,input().split())
price = map (int,input().split())
ans = 0
for i in range(num):
  if value[i] > price[i] :
      income = value[i] - price[i]
      ans += income
print(ans)

Submission status: Runtime Error

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

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

W = [v-c for v, c in zip(V, C) if (v-c) > 0]
print(sum(W)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
x = []

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

x.sort()

y = 0

i = n-1

while x[i] >= 0 and i >= 0 :
    y += x[i]
    i += -1

print(y)

Submission status: Runtime Error

Solution code:
N = int(input())
cost = [int(c)-int(v) for c,v in zip(input(), input())]
print(sum([c if c>0 else 0 for c in cost]))

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list()
for benefit, cost in a, b:
  if benefit - cost > 0:
    c.append(benefit - cost)
print(sum(c))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())
V=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
res=0
for vv cc in zip(V,C):
  if vv-cc>0:
    res=res+vv-cc
print(res)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
import itertools

N = int(input())

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

ans = -1

for condition in itertools.product(range(2),repeat=N):

    cond_nparr = np.array(condition)

    x = np.sum(V[cond_nparr]) - np.sum(C[cond_nparr])

    ans = max(ans, x)

print(ans)

Submission status: Runtime Error

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

N = []
for i, v in enumerate(V):
    N.append(V[i]-C[i])

N.sort(reverse=True)

result = 0
for n in N:
    if 0<n:
        result += n
    else:
        break

print(result)

Submission status: Runtime Error

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
V = [int(_) for _ in stdin.readline().rstrip().split()]
V_c =V.copy()
C = [int(_) for _ in stdin.readline().rstrip().split()]
C_c =C.copy()
for i in range(N):
    if V[i]<C[i]:
        V_c.pop(i)
        C_c.pop(i)
print(sum(V_c)-sum(C_c))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
v_lst = list(map(int,input().split()))
c_lst = list(map(int,input().split()))
ans_lst = []


for i in range(n):
    ans_lst.append(v_lst[i]-c_lst[i])
ans_lst.sort(reverse=True)

ans = 0
i = 0
while(ans_lst[i] > 0 and i < len(ans_lst)):
    ans += ans_lst[i]
    i += 1

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
vs = input().split(" ")
cs = input().split(" ")

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

print(xy)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
v_lst = list(map(int,input().split()))
c_lst = list(map(int,input().split()))
ans_lst = []


for i in range(n):
    ans_lst.append(v_lst[i]-c_lst[i])
ans_lst.sort(reverse=True)

ans = 0
i = 0
while(ans_lst[i] > 0):
    ans += ans_lst[i]
    i += 1

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

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

print(ans)

Submission status: Runtime Error

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

P = sorted(P)[::-1]
i,ans = 0,0

while P[i] > 0:
    ans += P[i]
    i += 1
print(ans)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <cstdio>
#include <sstream>

#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>

#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

//////////////////////////////////////////////////

int main(){
    int n;
    cin >> n;
    vi c(n);
    vi v(n);
    for(auto && x:v)cin >> x;
    for(auto && x:c) cin >> x;
    int ret = 0;
    for(int i=0;i<n;i++){
        ret += max(v[i] - c[i], 0);
    }
    cout << ret << endl;
    return 0;
}