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()))
suf = 0
for i in range (n):
  suf += b[i]
  if a[i - 1]  + 1 == a[i]:
    suf += c[a[i - 1] - 1]
print(suf)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
suf = 0
for i in range (n):
  suf += b[i]
  if (i != n - 1 )and(a[i]  + 1 == a[i+1]):
    suf += c[i]
print(suf)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
suf = 0
for i in range (n):
  suf += b[i]
  if a[i]  + 1 == a[i+1]:
    suf += c[i]
print(suf)

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
suf = 0
for i in range (n):
  suf += b[(a[i])]
  if (i != n - 1 )and(a[i]  + 1 == a[i+1]):
    suf += c[i]
print(suf)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
suf = 0
for i in range (n):
  suf += b[a[i]]
  if (i != n - 1 )and(a[i]  + 1 == a[i+1]):
    suf += c[a[i]]
print(suf)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
suf = 0
for i in range (n):
  menu = a[i]
  suf += b[menu]
  if (a[i] != n - 1 )and(a[i]  + 1 == a[i+1]):
    suf += c[menu]
print(suf)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
suf = 0
for i in range (n):
  suf += b[i]
  if a[i - 1]  + 1 == a[i]:
    suf += c[a[i - 1] - 1]
print(suf)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
suf = 0
for i in range(n):
  suf += b[i]
  if a[i]  + 1 == a[i+1]:
    suf += c[i]
print(suf)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
suf = 0
for i in range (n):
  men1 = a[i]
  men2 = a[i + 1] 
  suf += b[men1]
  if (i != n - 1 )and(men1 + 1 == men2):
    suf += c[men1]
print(suf)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
suf = 0
for i in range (n):
  suf += b[a[i - 1] ]
  if (a[i] != n )and(a[i - 1]  + 1 == a[i]):
    suf += c[a[i - 1]]
print(suf)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
suf = 0
for i in range (n):
  suf += b[a[i]]
  if (i != n - 1 )and(a[i]  + 1 == a[i+1]):
    suf += c[i]
print(suf)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
suf = 0
for i in range (n):
  if men1 != n-1:
  	men1 = a[i]
  	men2 = a[i + 1] 
  	suf += b[men1]
  	if (men1 + 1 == men2):
    	suf += c[men1]
  else:
    men1 = a[i]
    suf += b[men1]
print(suf)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
suf = 0
for i in range (n):
  suf += b[a[i]]
  if (i != n - 1 )and(a[i]  + 1 == a[i+1]):
    suf += c[i]
print(suf)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
suf = 0
for i in range (n):
  men1 = a[i]
  men2 = a[i + 1] 
  suf += b[men1]
  if (men1 != n - 1 )and(men1 + 1 == men2):
    suf += c[men1]
print(suf)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
suf = 0
for i in range (n):
  suf += b[i]
  if i >= 1 and a[i - 1]  + 1 == a[i]:
    suf += c[a[i - 1] - 1]
print(suf)


Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted