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: Wrong Answer

Solution code:
import itertools
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
xy = []
for i in range(n):
    for h in itertools.combinations(range(0,n),i):
        x = 0
        y = 0
        for j in h:
            x += v[j]
            y += c[j]
        xy.append(x-y)
print(max(xy))

Submission status: Wrong Answer

Solution code:
n=int(input());v=list(map(int,input().split()));c=list(map(int,input().split()))
d1=v+[v[i]+v[j] for i in range(n) for j in range(i+1,n)]
d2=c+[c[i]+c[j] for i in range(n) for j in range(i+1,n)]
d1.append(0);d2.append(0)
print(max([i-j for i,j in zip(d1,d2)]))

Submission status: Wrong Answer

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

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

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

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



main()

Submission status: Wrong Answer

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

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

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

print(max(list))

Submission status: Wrong Answer

Solution code:
n = raw_input()
cis = map(int, raw_input().split(' '))
vis = map(int, raw_input().split(' '))
r= 0
for c,v in zip(cis, vis):
  r += max(0,v - c)
print r

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = []
p = []
ans.append(0)


for i in range(2**n):
  tmp = [0]*n
  for j in range(n):
    if i >> j & 1:
      tmp[j] = 1
  p.append(tmp)

for i in range(len(p)-1):
  tv = 0
  tc = 0
  for j in range(n):
    if(p[i][j] == 1):
      tc = tc + c[j]
      tv = tv + v[j]
  ans.append(tv-tc)
print(max(ans))

Submission status: Wrong Answer

Solution code:
# 初期入力
import numpy as np
import sys
input = sys.stdin.readline
N = int(input())
V = np.array(list(map(int, input().split())))
C = np.array(list(map(int, input().split())))

#どの宝石を選ぶか全探索
v_c_sum=[]
for i in range(2**N):
    bi =str(bin(i)).lstrip("0b")
    v =V[np.where([int(i) for i in bi])]
    c =C[np.where([int(i) for i in bi])]
    v_c_sum.append(sum(v) - sum(c))
print(max(v_c_sum))

Submission status: Wrong Answer

Solution code:
# 初期入力
import numpy as np
import sys
input = sys.stdin.readline
N = int(input())
V = np.array(list(map(int, input().split())))
C = np.array(list(map(int, input().split())))

#どの宝石を選ぶか全探索
v_c_sum=[]
from itertools import combinations
for i in range(N+1):
    for t in combinations(range(N), i):
        print(t)

        v =np.sum(V[list(t)])
        c =np.sum(C[list(t)])
        v_c_sum.append(v-c)
print(max(v_c_sum))

Submission status: Wrong Answer

Solution code:
import time
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
start = time.time()
y = 0
for i in range(2 ** n):
  v_total = 0
  c_total = 0
  for j in range(n):  # このループが一番のポイント
    if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
      v_total += v[j]
      c_total += c[j]
  if (v_total-c_total) > y:
    y = v_total-c_total
print(y)
end_time = time.time() - start
print(end_time)

Submission status: Wrong Answer

Solution code:
from sys import argv

debug = "a" in argv
n = int(input())
v = tuple(map(int, input().split()))
c = tuple(map(int, input().split()))
p = []
pa = p.append
u = 0
for x, y in zip(v, c):
    pa((x - y, u))
    u += 1
p = sorted(p, key=lambda x: x[0])
if debug:
    print(p)
try:
    i1 = p[-1][1]
    i2 = p[-2][1]
except IndexError:
    print(0)
    exit()
if debug:
    print(i1)
    print(i2)
if debug:
    print("end debug")
ans = (v[i1] + v[i2]) - (c[i1] + c[i2])
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
difference = sorted([x1 - x2 for (x1, x2) in zip(v, c)], reverse=True)
print(difference[0] + difference[1]) if len(difference) >= 2 else print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
max = 0
a = [0]
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
V.sort(reverse = True)
C.sort(reverse = True)
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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
quant = int(input())
st=input().split(" ")
st2=input().split(" ")
v=[]
c=[]

for q in st:
    v.append(int(q))
for r in st2:
    c.append(int(r))

minimo=0
for i in range(quant):
    for k in range(i+1,quant):
        
        x=v[i]+v[k]
        y=c[i]+c[k]

        if x-y>minimo:
            minimo=x-y
print(minimo)

Submission status: Wrong Answer

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

v.sort(reverse=True)
c.sort(reverse=True)

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: Wrong Answer

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(2 ** n):
        total = 0
        for j in range(n):  # このループが一番のポイント
            if ((i >> j) & 1):  # 順に右にシフト
                total = total+v[j]-c[j]   
    print(tmax)

Submission status: Wrong Answer

Solution code:
import itertools
a = int(input())
v = list(map(int, input().split()[:a]))
c = list(map(int, input().split()[:a]))
if v < c:
    print(0)
else:
    possible_v = list(itertools.combinations(v, 2))
    sum_v = [sum(v) for v in possible_v]
    possible_c = list(itertools.combinations(c, 2))
    sum_c = [sum(c) for c in possible_c]
    res = 0
    for v, c in zip(sum_v, sum_c):
        if v - c > res:
            res = v - c
    print(res)

Submission status: Wrong Answer

Solution code:
import itertools
a = int(input())
v = list(map(int, input().split()[:a]))
c = list(map(int, input().split()[:a]))
if v < c:
    print(0)
else:
    possible_v = list(itertools.combinations(v, len(v) -1))
    sum_v = [sum(v) for v in possible_v]
    possible_c = list(itertools.combinations(c, len(c) -1))
    sum_c = [sum(c) for c in possible_c]
    res = 0
    for v, c in zip(sum_v, sum_c):
        if v - c > res:
            res = v - c
    print(res)

Submission status: Wrong Answer

Solution code:
import itertools
a = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
if v < c:
    print(0)
else:
    possible_v = list(itertools.combinations(v, len(v) -1))
    sum_v = [sum(v) for v in possible_v]
    possible_c = list(itertools.combinations(c, len(c) -1))
    sum_c = [sum(c) for c in possible_c]
    res = 0
    for v, c in zip(sum_v, sum_c):
        if v - c > res:
            res = v - c
    print(res)

Submission status: Wrong Answer

Solution code:
import itertools
a = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
possible_v = list(itertools.combinations(v, len(v) -1))
sum_v = [sum(v) for v in possible_v]
possible_c = list(itertools.combinations(c, len(c) -1))
sum_c = [sum(c) for c in possible_c]
res = 0
for v, c in zip(sum_v, sum_c):
    if v - c > res:
        res = v - c
print(res)

Submission status: Wrong Answer

Solution code:
import itertools
a = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
possible_v = list(itertools.combinations(v, 2))
max_v = [sum(v) for v in possible_v]
possible_c = list(itertools.combinations(c, 2))
max_c = [sum(c) for c in possible_c]
if not max_v and not max_c:
    if v < c:
        print(0)
    else:
        print(v - c)
else:
    res = 1
    for v, c in zip(max_v, max_c):
        if v - c > res:
            res = v - c
    print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
line = input()
v = [int(i) for i in line.split()]
line = input()
c = [int(k) for k in line.split()]
diferenca1=0
dif = []
for j in range(0, n, 1):
    if v[j]-c[j]>diferenca1:
        diferenca1=v[j]-c[j]
    diferenca2= v[j]-c[j]
    for t in range(0, n, 1):
        if t!=j:
            if (v[j]+v[t])-(c[j]+c[t])>diferenca1:
                diferenca1=(v[j]+v[t])-(c[j]+c[t])
            diferenca2=diferenca2+(v[t]-c[t])
    dif.append(diferenca2)
dif.sort()
if dif[-1]>diferenca1:
    print(dif[-1])
else:
    print(diferenca1)

Submission status: Wrong Answer

Solution code:
N=int(input())
v=[]
c=[]
for x in input().split():
    v.append(int(x))
for x in input().split():
    c.append(int(x))
X=v[0]+v[N-1]
Y=c[0]+c[N-1]
print(X-Y if (X-Y)>=0 else 0)

Submission status: Wrong Answer

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

new=[v[i]-c[i] for i in range(n)]
new.sort()
if len(new)>=2:
    print(new[-2]+new[-1])
else:
    print(max(new[0],0))

Submission status: Wrong Answer

Solution code:
n =int(input())
v =list(map(int ,input().split()))
c =list(map(int ,input().split()))
a =[]
if n ==1:
    a.append(0)
    
else:
    for i in range(n):
        for j in range(n):
            x =v[i] +v[j]
            y =c[i] +c[j]
            if not i == j:
                a.append(x-y)
print(max(a))

Submission status: Wrong Answer

Solution code:
n =int(input())
v =list(map(int ,input().split()))
c =list(map(int ,input().split()))
a =[]
if n ==1:
    print(0)
    
else:
    for i in range(n):
        for j in range(n):
            x =v[i] +v[j]
            y =c[i] +c[j]
            if not i == j:
                a.append(x-y)
    print(max(a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
a=["0"]
for i in range(n):
    for j in range(n-1):
        if (v[i]+v[j+1])-(c[i]+c[j+1])>0 and v[i]!=v[j+1] and c[i]!=c[j+1]:
            a+=str((v[i]+v[j+1])-(c[i]+c[j+1]))
        elif (v[i]+v[j+1])-(c[i]+c[j+1])<=0:
            print(0)
a=sorted(a,reverse=True)
print(a[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
a=["0"]
for i in range(n):
    for j in range(n-1):
        if (v[i]+v[j+1])-(c[i]+c[j+1])>0 and v[i]!=v[j+1] and c[i]!=c[j+1]:
            a+=str((v[i]+v[j+1])-(c[i]+c[j+1]))
a=sorted(a,reverse=True)
print(a[0])

Submission status: Wrong Answer

Solution code:
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  n = int(input())
  V = list(map(int,input().split()))
  C = list(map(int,input().split()))
  if n == 1:
    print(0)
    exit()
  N = [0] * n
  for i in range(n):
    N[i] = V[i] - C[i]
  N = sorted(N,reverse=True)
  print(N[0]+N[1])
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
n = int(input())
v = map(int, input().split())
c = map(int, input().split())
ans = 0
for i, j in zip(v, c):
  if i - j > 0:
    ans = i - j
print(ans)

Submission status: Wrong Answer

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

ans = 0
for i in range(n):
  for j in range(i+1, n):
    x = v[i] + v[j]
    y = c[i] + c[j]
    if x-y > ans:
      ans = x-y
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
V = input().split()
C = input().split()
cost = []
x = 0
for i in range(N):
    cost.append(int(V[int(i)]) - int(C[int(i)]))
print(cost)
print(sorted(cost,reverse=True))
for i in range(N):
    if cost[i] > 0:
        x = x + int(cost[i])
print(x)

Submission status: Wrong Answer

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(ans, v[i]-c[i])

  for j in range(n):
    if i == j:
      continue
    ans = max(ans, (v[i]+v[j])-(c[i]+c[j]))

  ans = max(ans, sum(v)-sum(c))

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
*a,=map(int,input().split())
*b,=map(int,input().split())
ans=0
su=0
s=0
j=0
for i in range(1,2**n):
    su=0
    s=0
    if i&(i-1)==0:
        continue
    for j in range(n):
        if (i>>j)&1:
            su+=a[j]
            s+=b[j]

    if su-s>ans:
        ans=su-s
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = []
Y = []

for x in map(int, input().split()):
    X.append(x)

for y in map(int, input().split()):
    Y.append(y)

d_list = []

for i in  range(N):
    d = X[i] - Y[i]
    if d > 0:
        d_list.append(d)

if d_list:
    ans = max(d_list) + min(d_list)
    if ans <=0:
        print(0)
    else:
        print(ans)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = []
Y = []

for x in map(int, input().split()):
    X.append(x)

for y in map(int, input().split()):
    Y.append(y)

d_list = []

for i in  range(N):
    d = X[i] - Y[i]
    if d > 0:
        d_list.append(d)

if d_list:
    print(max(d_list) + min(d_list))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np

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

ans = 0
for k in range(1, N+1):
    chosen = list(itertools.combinations(range(N), k))
    for a in range(np.shape(chosen)[0]):
        X = 0
        Y = 0
        for b in range(np.shape(chosen)[1]):
            idx = chosen[a][b]
            X += V[idx]
            Y += C[idx]
            if ans <= (X - Y):
                ans = X - Y
print("ans", ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=[]
for i in range(2**n):
	sum_v=0
	sum_c=0
	for j in range(n):
		if (i>>j)&1:
			sum_v+=v[j]
			sum_c+=c[j]
			ans.append(sum_v-sum_c)
print(max(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
R = []
for s in range(N):
    R.append(V[s] - C[s])
if len(R) == 1:
    print(0)
    quit()
R.sort()
print(R[-1] + R[-2])

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[0]*n
v=list(map(int,input().split()))
c=list(map(int,input().split()))
if n==1:
    if v[0]-c[0]<=0:
        print("0")
    else:
        print(v[0]-c[0])
    exit()
for i in range(n):
    a[i]=v[i]-c[i]
a.sort()
print(a[-1]+a[-2])

Submission status: Wrong Answer

Solution code:
a=int(input())
b=list(map(int,input().split()))
c=list(map(int,input().split()))
if a==1:
    if b[0]-c[0]<0:
        print("0")
    else:
        print(b[0]-c[0])
    exit()

d=[b[i]-c[i] for i in range(a)]
d.sort(reverse=True)

m1=d[0]
m2=d[1]
print(m1+m2)

Submission status: Wrong Answer

Solution code:
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
vc=list(reversed(sorted(list(zip(v,c)))))
ans=0
vi=0
ci=0
for i in range(n):
	vi+=vc[i][0]
	ci+=vc[i][1]
	if(ans < vi-ci):
		ans=vi-ci
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

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

print(a)

Submission status: Wrong Answer

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

cal = []
for i in range(0,n):
    cal.append(v[i]-c[i])
cal.sort(reverse=True)
print(cal)
ans = 0
for j in range(0,n):
    if cal[j] < 0:
        break
    ans += cal[j]
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
v=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
vv=[]
cc=[]
ans=0
if n==1:
  ans = v[0]-c[0]
else:
  for i in range(n):
    vv.append(v[i])
    cc.append(c[i])
    for j in range(i+1, n):
      vv.append(vv[-1]+v[j])
      cc.append(cc[-1]+c[j])
  for i in range(len(vv)):
    ans=max(ans,vv[i]-cc[i])
if ans < 0:
  print(0)
else:  
  print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
v=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
max=0
if n==1:
  max = v[0]-c[0]
else:
  for i in range(n):
    for j in range(i+1, n):
      temp = (v[i]+v[j]) - (c[i]+c[j])
      if temp > max:
        max = temp
if max < 0:
  print(0)
else:  
  print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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):
    ans += min(v - c, 0)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()

ans = 0

ALEN = (len(S))
 
B = list(S)
 
 
 
B_re =  list(reversed(B))
 
ans = 0
 

 
for i in range(ALEN):
  if B[i] != B_re[i]:
        ans = ans+1
    
if ans % 2 == 0:
    print(ans//2)
elif ans %2 != 0:
    print((ans//2) +1)
elif ans == 0:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
a = 0
b = 0
l = []
while len(l) < N*(N-1)//2:
  if b+1 != N:
    X = V[a] + V[b+1]
    Y = C[a] + C[b + 1]
    l.append(X - Y)
    b += 1
  else:
    a += 1
    b = a
print(max(l) if len(l) > 0 else 0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
H = list(map(int, input().split()))
count = 0
M = 0
for i in range(N):
  if H[i]>=M:
    count += 1
    M = H[i]
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
H = list(map(int, input().split()))
count = 0
M = 0
for i in range(N):
  print(H[i])
  if H[i]>=M:
    count += 1
    M = H[i]
print(count)

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
N = int(input())
H = list(map(int,input().split()))
count = 1
for i in range(1,N):
    if max(H[:i]) <= H[i]:
        count += 1
print(count)

Submission status: Wrong Answer

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

wei = [ list(i) for i in zip(V,C)]
c = 0



for i in range(0,len(wei)):
    for k in range(1,len(wei)):
        if i == k:
            break
        X = wei[i][0] + wei[k][0]
        Y = wei[i][1] + wei[k][1]
        cost = X - Y
        if cost > c:
            c =  cost

if N == 1:
    c = 0
print(c)

Submission status: Wrong Answer

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

wei = [ list(i) for i in zip(V,C)]
c = 0


if N == 1:
    c = 0

for i in range(0,len(wei)):
    for k in range(1,len(wei)):
        if i == k:
            break
        X = wei[i][0] + wei[k][0]
        Y = wei[i][1] + wei[k][1]
        cost = X - Y
        if cost > c:
            c =  cost


print(c)

Submission status: Wrong Answer

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

wei = [ list(i) for i in zip(V,C)]
c = 0
for i in range(0,len(wei)):
    for k in range(1,len(wei)):
        if i == k:
            break
        X = wei[i][0] + wei[k][0]
        Y = wei[i][1] + wei[k][1]
        cost = X - Y
        if cost > c:
            c =  cost


print(c)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
      
sumV = 0
sumC = 0
maxi = 0
for i in range(n):
    sumV += v[i]
    sumC += c[i]
    maxi = max(sumV-sumC,maxi)
print(maxi)

Submission status: Wrong Answer

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

ret = - float('inf')
for i in range((2 ** n) + 1):
    total_cost = 0
    total_value = 0
    binary = bin(i)[2:]
    for i, b in enumerate(binary):
        if b == '1':
            total_cost += cs[i]
            total_value += vs[i]
    ret = max(ret, total_value - total_cost)
print(ret)

Submission status: Wrong Answer

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

total_v = 0

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

Submission status: Wrong Answer

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]

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools

def q40(n, v, c):
    a = []
    
    for i in zip(v, c):
        a.append(i)
    
    m = 0
    for i in range(n):
        for j in itertools.combinations(a, i):
            #print(j)
            x = 0
            y = 0
            for k, l in j:
                x += k
                y += l
            if m < x - y:
                m = x -y
    return m
    
N=int(input())
V=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
print(q40(N, V, C))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())
x =list(map(int, input().split()))
y =list(map(int, input().split()))
diff = [x[i]-y[i] for i in range(n)]
num = 0
for d in diff:
    if(d > 0):
        num += d

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
values = list(map(int,input().split()))
costs = list(map(int,input().split()))
dictionary = []
for v in range(N):
  dictionary.append([values[v],costs[v]])
x,y=0,0
sort_dict = sorted(dictionary,reverse=True)
result = []
for i in range(N):
  if i+1<N and sort_dict[i][0] > sort_dict[i][1] and sort_dict[i][0] - sort_dict[i][1]>0:
    result.append(sort_dict[i][0]-sort_dict[i][1])
print(sum(result))

Submission status: Wrong Answer

Solution code:
N = int(input())
values = list(map(int,input().split()))
costs = list(map(int,input().split()))
dictionary = []
for v in range(N):
  dictionary.append([values[v],costs[v]])
x,y=0,0
sort_dict = sorted(dictionary,reverse=True)
result = []
for i in range(N):
  if i+1<N and sort_dict[i][0] > sort_dict[i][1]:
    result.append(sort_dict[i][0]-sort_dict[i][1])
print(sum(result))

Submission status: Wrong Answer

Solution code:
N = int(input())
values = list(map(int,input().split()))
costs = list(map(int,input().split()))
dictionary = []
for v in range(N):
  dictionary.append([values[v],costs[v]])
x,y=0,0
sort_dict = sorted(dictionary,reverse=True)
for i in range(N):
  if i+1<N and sort_dict[i][0] > sort_dict[i][1]:
    x = sort_dict[i][0] + sort_dict[i+1][0]
    y = sort_dict[i][1] + sort_dict[i+1][1]
    break
  elif i+1>=N:
    xs = []
    ys = []
    for s in sort_dict:
      xs.append(s[0])
      ys.append(s[1])
    sxs = sorted(list(set(xs)),reverse=True)
    sys = sorted(list(set(ys)),reverse=True)
    x = sum(sxs[:1])
    y = sum(sys[:1])
print(0 if x-y<0 else x-y)

Submission status: Wrong Answer

Solution code:
N = int(input())
values = list(map(int,input().split()))
costs = list(map(int,input().split()))
dictionary = []
for v in range(N):
  dictionary.append([values[v],costs[v]])
x,y=0,0
sort_dict = sorted(dictionary,reverse=True)
for i in range(N):
  if sort_dict[i][0] > sort_dict[i][1] and (i+1)<=N:
    x = sort_dict[i][0] + sort_dict[i+1][0]
    y = sort_dict[i][1] + sort_dict[i+1][1]
    break
print(x-y)

Submission status: Wrong Answer

Solution code:
N = int(input())
values = sorted(list(map(int,input().split())), reverse=True)
costs = sorted(list(map(int,input().split())), reverse=True)
x,y = 0,0
for i in range(N):
  if values[i] > costs[i] and (i+1)<=N:
    x = values[i]+values[i+1]
    y = costs[i]+costs[i+1]
    break
print(abs(x-y))

Submission status: Wrong Answer

Solution code:
#B

N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
List = []
for i in range(N):
    List.append(V[i]-C[i])
List.sort()
for i in List:
    if i > 0:
        print(sum(List[i:]))
        exit()
print('0')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

T = V[0] + V[-1]
U = C[0] + C[-1]
A = T - U
print(A)

Submission status: Wrong Answer

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

for i in range(N):
	lst.append(V[i] - C[i])
  
high_score = 0
  
for i in range(2 ** N):
	a = list(str(bin(i))[2:])
	for k in range(N - len(a)):
		a.insert(0, "0")
	b = list(map(int, a))
	print(b)
	score = 0
	for j in range(len(b)):
		score += lst[j] * b[j]
	if high_score < score:
		high_score = score
    
print(high_score)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for a, b in zip(v,c):
    ans +=max(a-b,0)
ans

Submission status: Wrong Answer

Solution code:
import sys

N=input()
if N.isdecimal() ==0 or int(N)<1 or int(N)>20 :
    print("error")
    sys.exit()

N=int(N)

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

for i in range(N):
    if C[i]<1 or C[i]>20 or V[i]<1 or V[i]>20:
        print("error")
        sys.exit()

diff=0
max_profit=0



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

print(max_profit)

Submission status: Wrong Answer

Solution code:
import sys

N=input()
if isinstance(N,int)==0 or N<1 or N>20 :
    print("error")
    sys.exit()

N=int(N)

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

for i in range(N):
    if C[i]<1 or C[i]>20 or V[i]<1 or v[i]>20:
        print("error")
        sys.exit()

diff=0
max_profit=0



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

print(max_profit)

Submission status: Wrong Answer

Solution code:
n = int(input())

v_list = [ int(v) for v in input().split() ]
c_list = [ int(v) for v in input().split() ]

ans = sum([ max( 0, (v_list[i]-c_list[i]) ) for i in range(n) ])