Problem: Takahashi went to an all-you-can-eat buffet with N kinds of dishes and ate all of them (Dish 1, Dish 2, \ldots, Dish N) once.  The i-th dish (1 \leq i \leq N) he ate was Dish A_i.  When he eats Dish i (1 \leq i \leq N), he gains B_i satisfaction points.  Additionally, when he eats Dish i+1 just after eating Dish i (1 \leq i \leq N - 1), he gains C_i more satisfaction points.  Find the sum of the satisfaction points he gained.

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
manzoku = sum(B)
i = 1
while N>i:
    if A[i]-A[i-1] == 1:
        manzoku += C[i]
    i += 1
print(manzoku)


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
manzoku = sum(B)
i = 0
while N>i:
    if A[i+1]-A[i] == 1:
        manzoku += C[i]
    i += 1
print(manzoku)


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
i=0
manzoku=0
while i<N:
    manzoku += B[i]
    i += 1
if A[0]=1:
    manzoku += sum(C)
else:
    manzoku += sum(C) - C[A[0]]

print(manzoku)


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
manzoku = sum(B)
i = 1
while N>i:
    if A[i]-A[i-1] == 1:
        manzoku += C[i-1]
    i += 1
print(manzoku)


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

n=int(0)
manzoku=int(0)
hantei = int(1)
while n<N:
    manzoku += B[n]
    n += 1

if A[0] == hantei:
        manzoku += sum(C)
else:
        manzoku += sum(C) - C[A[0]-1]

print(manzoku)


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

n=int(0)
manzoku=int(0)
hantei = int(1)
while n<N:
    manzoku += B[n]
    n += 1

if A[0] == hantei:
        manzoku += sum(C)
else:
        manzoku += sum(C) - C[A[0]]

print(manzoku)


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
manzoku = sum(B)
i = 1
while N>i:
    if A[i]-A[i-1] == 1:
        manzoku += C[i-1]
    i += 1
print(manzoku)


N = int(input())
A = [0] * N
B = [0] * N
C = [0] * N
for i in range(N):
    A[i], B[i], C[i] = map(int, input().split())

j=int(0)
manzoku=int(0)
while j<N:
    manzoku += B[j]
    j += 1
    if A[0]=1:
        manzoku += sum(C)
    else:
        manzoku += sum(C) - C[A[0]]

print(manzoku)


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
n=int(0)
manzoku=int(0)
hantei = int(1)
if A[0] == hantei:
        manzoku += sum(C) + sum(B)
else:
        manzoku += sum(C) - C[A[0]-1] +sum(B)

print(manzoku)


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
manzoku = sum(B)
i = 1
while N>i-1:
    if A[i]-A[i-1] == 1:
        manzoku += C[i-1]
    i += 1
print(manzoku)


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
n=int(0)
manzoku=int(0)
hantei = int(1)
if A[0] == hantei:
        manzoku += sum(C)
        while n<N:
            manzoku += B[n]
            n += 1
    else:
        manzoku += sum(C) - C[A[0]-2]
        while n<N:
            manzoku += B[n]
            n += 1

print(manzoku)


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
i=0
manzoku=0
j=0
while i<N:
    manzoku += B[i]
    i += 1
if A[0]=1:
    manzoku += sum(C)
else:
    manzoku += sum(C) - C[A[0]]

print('manzoku')


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
i = 1
manzoku = sum(B)
while N>i:
    if A[i]-A[i-1] == 1:
      j = A[i-1]
      manzoku += C[j-1]
    i += 1
print(manzoku)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted