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()))
s=0
for i in range(N):
  if i>=1 and A[i]==A[i-1]+1:
    s=s+B[A[i]-1]+C[i-1]
  else:
    s=s+B[A[i]-1]
print(s)

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
def main():
  for i in range(A):
    if A[i+1]==A[i]+1:
      B[A[i+1]]=B[A[i+1]]+C[i]
    print(sum(B[A[i]])
main()

N=int(input())
A=map(int,input().split())
B=map(int,input().split())
C=map(int,input().split())
A.split()
B.split()
C.split()
s=B[A[0]-1]
for i in range(1,len(S)+1):
  s+=B[A[i]-1]
  if A[i]==A[i-1]+1:
    s+=C[i-1]
print(s)

N=int(input())
A=map(int,input().split())
B=map(int,input().split())
C=map(int,input().split())
s=B[A[0]-1]
for i in range(1,len(S)+1):
  s+=B[A[i]-1]
  if A[i]==A[i-1]+1:
    s+=C[i-1]
print(s)

N=int(input())
A=map(int,input().split())
B=map(int,input().split())
C=map(int,input().split())
s=0
for i in range(1,len(S)+1):
  s+=B[A[i-1]]
  if A[i]==A[i-1]+1:
    s+=C[i-1]
print(s)

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
s=0
for i in range(1,N+1):
  s+=B[A[i-1]]
  if i>=2 and A[i-1]==A[i-2]+1:
    s+=C[i-2]
print(s)



N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
def main():
  for i in range(A):
    if A[i]+1==A[i+1]:
      B[A[i+1]]=B[A[i+1]]+C[i]
  print(sum(B[A[i]])
main()

N=int(input())
A=map(int,input().split())
B=map(int(input().split())
C=map(int,input().split())
A.split()
B.split()
C.split()
for i in range(N):
  s=sum(B[i]):
  if A[i+1]==A[i]+1:
    s=s+C[i]
print(s)

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
s=0
for i in range(N):
  s+=B[A[i]-1]
  if i>=1 and A[i]==A[i-1}+1:
    s+=C[i-1]
print(s)

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
s=0
for i in range(N):
  if i>=1 and A[i]==A[i-1}+1:
    s=s+B[A[i]-1]+C[i-1]
  else:
    s=s+B[A[i]-1]
print(s)

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
def main():
  for i in  range(A):
    if A[i]+1==A[i+1]:
      B[A[i+1]]=B[A[i+1]]+C[i]
  print(sum(B[A[i]])
main()


N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
s=0
for i in range(N):
  s+=B[A[i]-1]
  if i>=1 and A[i]==A[i-1}+1:
    s+=C[i]
print(s)

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
s=0
for i in range(0,N):
  s+=B[A[i]-1]
  if i>=1 and A[i]==A[i-1}+1:
    s+=C[i-1]
print(s)

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
s=0
temp=""
for i in A:
  s+=B[i-1]
  if temp==i-1:
    s+=C[temp-1]
  temp=i
print(s)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted