Problem: 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.

Submission attempts (in order):
N=int(input())
V=list(map(int, input().split()))
C=list(map(int, input().split()))
ans_max=0

for j in range(N-1):
    for i in range(j+1,N):
        X=V[j]+V[i]
        Y=C[j]+C[i]
        ans=X-Y
        if ans_max<ans:
            ans_max=ans
        if N-j<2:
            for f in range(j+2,N):
                X = V[j] + V[i]+V[f]
                Y = C[j] + C[i]+C[f]
                ans = X - Y
                if ans_max < ans:
                    ans_max = ans
        else:
            break

print(ans_max)

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

for j in range(N-1):
    for i in range(j+1,N):
        X=V[j]+V[i]
        Y=C[j]+C[i]
        ans=X-Y
        if ans_max<ans:
            ans_max=ans
            for f in range(j+2,N):
                X = V[j] + V[i]+V[f]
                Y = C[j] + C[i]+C[f]
                ans = X - Y
                if ans_max < ans:
                    ans_max = ans
        
print(ans_max)

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

for j in range(N-1):
    for i in range(j+1,N):
        X=V[j]+V[i]
        Y=C[j]+C[i]
        ans=X-Y
        if ans_max<ans:
            ans_max=ans
        for f in range(j+2,N):
            X = V[j] + V[i]+V[f]
            Y = C[j] + C[i]+C[f]
            ans = X - Y
            if ans_max < ans:
                ans_max = ans

print(ans_max)

N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
ans_max = 0
V_ans=[]
C_ans=[]

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

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

for j in range(N-1):
    for i in range(j+1, N):
        X = V[j]+V[i]
        Y = C[j]+C[i]
        ans = X-Y

        if ans_max < ans:
            ans_max = ans

        if N-i < 2:
            for f in range(i+1, N):
                X = V[j] + V[i]+V[f]
                Y = C[j] + C[i]+C[f]
                ans = X - Y
                if ans_max < ans:
                    ans_max = ans

        else:
            break

print(ans_max)

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

for j in range(N-1):
    for i in range(j+1,N):
        X=V[j]+V[i]
        Y=C[j]+C[i]
        ans=X-Y
        if ans_max<ans:
            ans_max=ans
        if N-i<2:
            for f in range(j+2,N):
                X = V[j] + V[i]+V[f]
                Y = C[j] + C[i]+C[f]
                ans = X - Y
                if ans_max < ans:
                    ans_max = ans
        else:
            break

print(ans_max)

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

for j in range(N-1):
    for i in range(j+1,N):
        X=V[j]+V[i]
        Y=C[j]+C[i]
        ans=X-Y
        if ans_max<ans:
            ans_max=ans
        if N-j<=2:
            for f in range(j+2,N):
                X = V[j] + V[i]+V[f]
                Y = C[j] + C[i]+C[f]
                ans = X - Y
                if ans_max < ans:
                    ans_max = ans
        else:
            break

print(ans_max)


N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
ans_max = 0
V_ans=[]
C_ans=[]

for i in range(0,N):
    if V[i]>C[i]:
        V_ans.append(V[i])
        C_ans.append(C[i])

print(sum(V_ans)-sum(C_ans))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted