TnT/Multi_CodeNet4Repair huggingface dataset:
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):
import sys
n = int(sys.stdin.readline())
lia = list(map(int, sys.stdin.readline().split()))
lib = list(map(int, sys.stdin.readline().split()))
lic = list(map(int, sys.stdin.readline().split()))
s = sum(lib)
li = []
i = 0
while i < n-1:
  if lia[i+1] - lia[i] == 1:
    li.append(i)
for i in li:
  s += lic[i]
print(s)

import sys
n = int(sys.stdin.readline())
lia = list(map(int, sys.stdin.readline().split()))
lib = list(map(int, sys.stdin.readline().split()))
lic = list(map(int, sys.stdin.readline().split()))
s = sum(lib)
li = []
i = 0
while i < n-1:
  if lia[i+1] - lia[i] == 1:
    li.append(i)
  i += 1
for i in li:
  s += lic[i]
print(s)


import sys
n = int(sys.stdin.readline())
lia = list(map(int, sys.stdin.readline().split()))
lib = list(map(int, sys.stdin.readline().split()))
lic = list(map(int, sys.stdin.readline().split()))
s = sum(lib)
li = []
i = 0
while i < n-1:
  if lia[i+1] - lia[i] == 1:
    li.append(lia[i]-1)
  i += 1
for i in li:
  s += lic[i]
print(s)


Verdicts: Time Limit Exceeded

Wrong Answer

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

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


Verdicts: Wrong Answer

Accepted
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()) )	# 1 2 3 4 5 ...
B =        list( map(int, input().split()) )	# 1 2 3 4 5 ...
C =        list( map(int, input().split()) )	# 1 2 3 4 5 ...

ans=0

x=-1
for a in A:
	
	if a==x+1:
		ans+=C[a]
	else:
		ans+=B[a]
	x=a

print(ans)


n = int(input())

A =        list( map(int, input().split()) )	# 1 2 3 4 5 ...
B =        list( map(int, input().split()) )	# 1 2 3 4 5 ...
C =        list( map(int, input().split()) )	# 1 2 3 4 5 ...

ans=0

x=-2
for a in A:
	a-=1
	ans+=B[a]
	if a==x+1:
		ans+=C[a-1]
	x=a

print(ans)


Verdicts: Runtime Error

Accepted
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=[int(x)for x in input().split()]
B=[int(x)for x in input().split()]
C=[int(x)for x in input().split()]
ans=sum(B)
for i in range(len(A)-1):
    if A[i]+1==A[i+1]:
        print(A[i])
        ans+=C[A[i]-1]
print(ans)

N=int(input())
A=[int(x)for x in input().split()]
B=[int(x)for x in input().split()]
C=[int(x)for x in input().split()]
ans=sum(B)
for i in range(len(A)-1):
    if A[i]+1==A[i+1]:
        ans+=C[A[i]-1]
print(ans)

Verdicts: Wrong Answer

Accepted
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):
num = int(input())
order = input().split()
manzoku = input().split()
additional = input().split()

prev = 0
ans = 0
for i in range(num):
  ans += manzoku[i]
  if i = prev+1:
    ans += additional[i]
  prev += 1
  
print(ans)

num = int(input())
order = input().split()
order = [int(i) for i in order]
manzoku = input().split()
additional = input().split()

prev = -1
ans = 0
for i in order:
  ans += int(manzoku[i-1])
  if i == prev+1:
    ans += int(additional[i-2])
  prev = i
  
print(ans)

Verdicts: Runtime Error

Accepted
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 = input()
line1 = input()
line2 = input()
line3 = input()

a_list = line1.split(" ")
a_list = [int(a) for a in a_list]
b_list = line2.split(" ")
b_list = [int(b) for b in b_list]
c_list = line3.split(" ")
c_list = [int(c) for c in c_list]

temp = a_list[0]
ans = 0
for a in a_list:
    if a == temp + 1:
        ans = ans + b_list[a-1] + c_list[temp-1]
        print(ans)
    else:
        ans = ans + b_list[a-1]
        print(ans)
    temp = a
print(ans)


n = input()
line1 = input()
line2 = input()
line3 = input()

a_list = line1.split(" ")
a_list = [int(a) for a in a_list]
b_list = line2.split(" ")
b_list = [int(b) for b in b_list]
c_list = line3.split(" ")
c_list = [int(c) for c in c_list]

temp = a_list[0]
ans = 0
for a in a_list:
    if a == temp + 1:
        ans = ans + b_list[a-1] + c_list[temp-1]
    else:
        ans = ans + b_list[a-1]
    temp = a
print(ans)


Verdicts: Wrong Answer

Accepted
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 = input().split()
b = input().split()
c = input().split()

result = 0
j = 1
for i in a:
  m = int(i) - 1
  result += int(b[m])
  if not (m == 1) and (j + 1 == m):
      result += int(c[j])
  j = m
print(result)

n = int(input())
a = input().split()
b = input().split()
c = input().split()

result = 0
j = 0
for i in a:
  m = int(i) - 1
  result += int(b[m])
  if (not (j == 0)) and (j + 1 == m):
      result += int(c[j])
  j = m
print(result)

n = int(input())
a = input().split()
b = input().split()
c = input().split()

result = 0
j = 1
for i in a:
  m = int(i) - 1
  result += int(b[m])
  if not (m == 0) and (j + 1 == m):
      result += int(c[j])
  j = m
print(result)

n = int(input())
a = input().split()
b = input().split()
c = input().split()

result = 0
j = 0
isFirst = True
for i in a:
  m = int(i) - 1
  result += int(b[m])
  if (not (isFirst)) and (j + 1 == m):
      result += int(c[j])
  j = m
  isFirst = False
print(result)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
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):
print(int(input())**3)

N = int(input())
a = [int(i)-1 for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
cnt = 0
temp = N
for i in a:
  cnt += b[i]
  if temp+1 == i:
    cnt += c[i-1]
  temp = i
print(cnt)

Verdicts: Wrong Answer

Accepted
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 = map(int,input().split())
B = map(int,input().split())
C = map(int,input().split())

ans = 0
for i in range(N):
    ans+= B[i]

for i in range(N-1):
    if A[i]+1 ==A[i+1]:
        ans+= C[A[i]]

print(ans)

N = int(input())
A = input().split()
B = input().split()
C = input().split()

ans = 0
for i in range(N):
    ans+= int(B[i])

for i in range(N-1):
    if int(A[i])+1 ==int(A[i+1]):
        ans+=int(C[int(A[i])])

print(ans)

N = int(input())
A = input().split()
B = input().split()
C = input().split()

ans = 0
for i in range(N):
    ans+= int(B[i])

for i in range(N-1):
    if int(A[i])+1 ==int(A[i+1]):
        ans+=int(C[int(A[i])-1])

print(ans)

Verdicts: Runtime Error

Runtime Error

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

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

Verdicts: Wrong Answer

Accepted
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()))

ans = 0
pre = -1
for i in A:
  ans += B[i-1]
  if i == pre+1:
  	ans += C[i-1]
  pre = i
print(ans)

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

ans = 0
pre = -1
for i in A:
  ans += B[i-1]
  if i == pre+1:
  	ans += C[pre-1]
  pre = i
print(ans)

Verdicts: Runtime Error

Accepted
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()))
c = 0

for i in range(A-2):
    c += B[i]
print(c+B[N-1]+C[N-2])

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

pre = 0
for i in range(N):
    now = A[i] - 1
    c += B[now]
    if i != 0 and pre == now - 1:
        c += C[pre]
    pre = now
print(c)

Verdicts: Runtime Error

Accepted
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())
L = [int(i) for i in input().split()]
c = sum(int(i) for i in input().split())
C = [int(i) for i in input().split()]
for i in range(len(L)):
  if L[i] == L[i+1]:
    c += C[i-1]
print(c)

n = int(input())
L = [int(i) for i in input().split()]
c = sum(int(i) for i in input().split())
C = [int(i) for i in input().split()]
for i in range(len(L)-1):
  if L[i]+1 == L[i+1]:
    c += C[L[i]-1]
print(c)

Verdicts: Runtime Error

Accepted
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())) 
summ = 0 
for i in range(n-1): #pudging
    if a[i] + 1 == a[i + 1]: #pudging
        summ += c[a[i]] #pudging
        summ += b[a[i]] #pudging
    else: #pudging
        summ += b[a[i-1]] #pudging
print(summ) #pudging
#accepted
    

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


Verdicts: Runtime Error

Accepted
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()))

happy = 0
for i in range(N):
    happy += B[A[i]-1]

for j in range(N-1):
    if A[j+1] - A[j] == 0:
        happy +=  C[A[j]-1]

print(happy)

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

happy = sum(B)

for j in range(N-1):
    if A[j+1] - A[j] == 1:
        happy +=  C[A[j]-1]

print(happy)


Verdicts: Wrong Answer

Accepted
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):
while True:
    try:
        n = int(input())
        ans = 0
        last = lsta[0]
        lsta = list(map(int, input().split()))
        lstb = list(map(int, input().split()))
        lstc = list(map(int, input().split()))
        for i in range(n):
            ans += lstb[lsta[i]-1]
            if last + 1 == i:
                ans += lstc[last-1]
            last = lsta[i]
        print(ans)
    except:
        break

while True:
    try:
        n = int(input())
        ans = 0
        lsta = list(map(int, input().split()))
        lstb = list(map(int, input().split()))
        lstc = list(map(int, input().split()))
        last = lsta[0]
        for i in range(n):
            ans += lstb[lsta[i]-1]
            if last + 1 == lsta[i]:
                ans += lstc[last-1]
            last = lsta[i]
        print(ans)
    except:
        break

Verdicts: Wrong Answer

Accepted
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 = tuple(int(x) for x in input().split())
B = tuple(int(x) for x in input().split())
C = tuple(int(x) for x in input().split())

satisfy = sum(B)

for i in range(len(A)-1):
  if A[i+1]-A[i] is 1:
    satisfy += C[A[i]]

print(satisfy)

N = int(input())
A = tuple(int(x) for x in input().split())
B = tuple(int(x) for x in input().split())
C = tuple(int(x) for x in input().split())

satisfy = sum(B)

for i in range(N-1):
  if A[i+1]-A[i] is 1:
    satisfy += C[A[i]-1]

print(satisfy)


Verdicts: Runtime Error

Accepted
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()))

ans=sum(B)

for i in range(n-1):
	if A[i]+1==A[i+1]:
		ans+=C[i]

print(ans)

n = int(input())

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

ans=sum(B)

for i in range(n-1):
	if A[i]+1==A[i+1]:
		ans+=C[A[i]-1]

print(ans)

Verdicts: Wrong Answer

Accepted
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):
A, B = map(int, input().split())
plug = 1
cnt = 0
while plug < B:
  plug += A - 1
  cnt += 1
print(cnt)

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

X = 0
j = A[0]
for i in A:
  X += B[i-1]
  if i == j+1:
    X+= C[j-1]
  j = i
print(X)


Verdicts: Runtime Error

Accepted
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()))

ans = 0
for i in range(N):
  ans += B[A[i]]
  if A[i]+1 == A[i+1]:
    ans += C[A[i]]

print(ans)


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

ans = 0
for i in range(N):
  ans += B[A[i]-1]
  if i < N - 1 and A[i] == A[i+1]-1:
    ans += C[A[i]-1]

print(ans)


Verdicts: Runtime Error

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

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

Verdicts: Wrong Answer

Accepted
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())
dishes = list(map(int, input().split()))
satisfaction = list(map(int, input().split()))
additional = list(map(int, input().split()))

res = 0

for i in range(N-1):
    res += satisfaction[i]

    if dishes[i] + 1 == dishes[i+1]:
        res += additional[dishes[i] - 1]
    
    print(res)

print(res + satisfaction[-1])




N = int(input())
dishes = list(map(int, input().split()))
satisfaction = list(map(int, input().split()))
additional = list(map(int, input().split()))

res = 0

for i in range(N-1):
    res += satisfaction[i]

    if dishes[i] + 1 == dishes[i+1]:
        res += additional[dishes[i] - 1]

print(res + satisfaction[-1])




Verdicts: Wrong Answer

Accepted
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 = map(int, input().split())
B = map(int, input().split())
C = map(int, input().split())

s = 0
prev = 0
for f in A:
  if prev != 0:
    s += B[f-1]
    s += C[prev-1]
  else:
    s += B[f-1]
  prev = f
print(s)

N = int(input())
A = map(int, input().split())
B = map(int, input().split())
C = map(int, input().split())
add_s = 0
for order in range(N-1):
  cur_f = A[order]
  nxt_f = A[order+1]
  add_s += C[order] if nxt_f == cur_f + 1 else 0
  
print(sum(B) + add_s)


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
add_s = 0
for idx in range(N-1):
  cur_f = A[idx]
  nxt_f = A[idx+1]
  add_s += C[cur_f-1] if nxt_f == cur_f + 1 else 0

print(sum(B) + add_s)


Verdicts: Runtime Error

Runtime Error

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


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

Verdicts: Wrong Answer

Accepted
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):
import numpy as np

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

r = np.sum(B)
for i in range(N-1):
  if A[i] + 1 == A[i + 1]:
    r += C[A[i]]

print(r)

import numpy as np
 
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
r = np.sum(B)
for i in range(N-1):
  if A[i] + 1 == A[i + 1]:
    r += C[A[i]-1]

print(r)

Verdicts: Runtime Error

Accepted
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())
lista=list(map(int,input().split()))
listb=list(map(int,input().split()))
listc=list(map(int,input().split()))
list=[]
for i in range(n):
  if lista[i]==lista[i-1]+1:
    list.append(lista[i])
vonus=0
for x in list:
  vonus+=listc[x-1]
print(sum(listb)+vonus)

n=int(input())
lista=list(map(int,input().split()))
listb=list(map(int,input().split()))
listc=list(map(int,input().split()))
list=[]
for i in range(n):
  if lista[i+1]==lista[i]+1:
    list.append(lista[i])
vonus=0
for x in list:
  vonus+=listc[x-1]
print(sum(listb)+vonus)

n=int(input())
lista=list(map(int,input().split()))
listb=list(map(int,input().split()))
listc=list(map(int,input().split()))
list=[]
for i in range(n):
  if lista[i]==lista[i-1]+1:
    list.append(lista[i-1])
vonus=0
for x in list:
  vonus+=listc[x-1]
print(sum(listb)+vonus)

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

list=[]
for i in range(n-1):
  if a[i]+1==a[i+1]:
    list.append(a[i]-1)
vonus=0
for ll in list:
  vonus+=c[ll]
print(sum(b)+vonus)
  
    

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Accepted
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):
import sys
input = sys.stdin.readline

N = int(input())
AAA = list(map(int, input().split()))
BBB = list(map(int, input().split()))
CCC = list(map(int, input().split()))

n_satisfy = 0
for i, A in enumerate(AAA):
    B = BBB[A - 1]
    if i == 0:
        n_satisfy += B
    elif AAA[i - 1] + 1 != A:
        n_satisfy += B
    else:
        n_satisfy += B + CCC[A - 1 - 1]
    print(n_satisfy)

print(n_satisfy)


import sys
input = sys.stdin.readline

N = int(input())
AAA = list(map(int, input().split()))
BBB = list(map(int, input().split()))
CCC = list(map(int, input().split()))

n_satisfy = 0
for i, A in enumerate(AAA):
    B = BBB[A - 1]
    if i == 0:
        n_satisfy += B
    elif AAA[i - 1] + 1 != A:
        n_satisfy += B
    else:
        n_satisfy += B + CCC[A - 1 - 1]

print(n_satisfy)


Verdicts: Wrong Answer

Accepted
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 = map(int, input().split())
b = map(int, input().split())
c = map(int, input().split())

ans = 0
for i in range(n-1):
  if a[i] + 1 == a[i+1]:
    ans += c[i]
  
print(ans + sum(b))  

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n - 1):
    if a[i] + 1 == a[i + 1]:
        ans += c[i]

print(ans + sum(b))

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n - 1):
    if a[i] + 1 == a[i + 1]:
        ans += c[a[i]-1]

print(ans + sum(b))

Verdicts: Runtime Error

Wrong Answer

Accepted
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()))
sum = 0

A.append(0)

for i in range(N):
  sum += B[A[i]-1]
  if A[i+1] == A[i] + 1:
    sum += C[A[i]-1]
  print(sum)

print(sum)

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

A.append(0)

for i in range(N):
  sum += B[A[i]-1]
  if A[i+1] == A[i] + 1:
    sum += C[A[i]-1]

print(sum)

Verdicts: Wrong Answer

Accepted
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()))

a = 0
ans = 0
for i in A:
  ans += B[i - 1]
  if a == i - 1:
    ans += C[a - 1]
  else:
    pass

print(ans)

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

ans = sum(B)

for i in range(N - 1):
  if A[i] + 1 == A[i + 1]:
    ans += C[A[i] - 1]

print(ans)

Verdicts: Wrong Answer

Accepted
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_lis = list(map(int,input().split()))
b_lis = list(map(int,input().split()))
c_lis = list(map(int,input().split()))

s = 0

for i in range(n):
  if a_lis[i+1] - a_lis[i] == 1:
    s += c_lis[a_lis[i]]
print(sum(b_lis)+s)

n = int(input())
a_lis = list(map(int,input().split()))
b_lis = list(map(int,input().split()))
c_lis = list(map(int,input().split()))
 
s = 0
 
for i in range(n-1):
  if a_lis[i+1] - a_lis[i] == 1:
    s += c_lis[a_lis[i]-1]
print(sum(b_lis)+s)

Verdicts: Runtime Error

Accepted
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()))

m = n-1
sumc = 0
for i in range(m):
    if a[i+1] == a[i]+1:
        if i+1 <= m:
            sumc += c[i]
#tmp = a[m]
#if m > 1:
#    if tmp <= m:
#        sumc -= c[tmp-1]
#if m == 1:
#    if tmp == 1:
#        sumc = 0
ans = sum(b)
ans += sumc

print(ans)



n = int(input())

a = list(map(int, input().split()))

b = list(map(int, input().split()))

c = list(map(int, input().split()))

m = n-1
sumc = 0
for i in range(m):
    if a[i+1] == a[i]+1:
        sumc += c[i]
#tmp = a[m]
#if m > 1:
#    if tmp <= m:
#        sumc -= c[tmp-1]
if m == 1:
    if tmp == 1:
        sumc = 0
ans = sum(b)
ans += sumc

print(ans)



n = int(input())

a = list(map(int, input().split()))

b = list(map(int, input().split()))

c = list(map(int, input().split()))

m = n-1
sumc = 0
for i in range(m):
    if a[i+1] == a[i]+1:
        sumc += c[i]
#tmp = a[m]
#if m > 1:
#    if tmp <= m:
#        sumc -= c[tmp-1]
#if m == 1:
#    if tmp == 1:
#        sumc = 0
ans = sum(b)
ans += sumc

print(ans)



n = int(input())

a = list(map(int, input().split()))

b = list(map(int, input().split()))

c = list(map(int, input().split()))

m = n-1
ans = 0
for i in range(n):
    ans += b[a[i]-1]
    if (i>0)and(a[i] == a[i-1]+1):
        ans += c[a[i-1]-1]

print(ans)


Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
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 = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
Total = sum(B)
for T in range(0,N-1):
    if A[T+1]-A[T]==1:
        Total += C[T]
print(Total)

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
Total = sum(B)
for T in range(0,N-1):
    if A[T+1]-A[T]==1:
        Total += C[A[T]-1]
print(Total)

Verdicts: Wrong Answer

Accepted
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()))

d = dict(zip(A, B))
ans = d[A[0]]

for i in range(1, N):
    if A[i] - A[i-1] == 1:
        ans += d[A[i]] + C[i-1]
    else:
        ans += d[A[i]]

print(ans)

N = int(input())

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

d = dict(zip(A, B))
ans = d[A[0]]

for i in range(1, N):
    if A[i] - A[i-1] == 1:
        ans += d[A[i]] + C[A[i-1] -1]
    else:
        ans += d[A[i]]

print(ans)

Verdicts: Wrong Answer

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


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

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


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


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


n=int(input())
a=list(int(input()))
b=list(int(input()))
c=list(int(input()))
p=0
for i in range(n):
  p+=b[a[i]]
  if　a[i]-a[i-1]==1:
    p+=c[i]
print(p)
  

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


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


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


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


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
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 = [int(i) - 1 for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

result = 0
for i in range(n):
  result += b[a[i]]
  if i > 1 and a[i-1] + 1 = a[i]:
    result += c[a[i-1]]
    
print(result)

n = int(input())
a = [int(i) - 1 for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

result = 0
for i in range(n):
  result += b[a[i]]
  if i > 0 and a[i-1] + 1 == a[i]:
    result += c[a[i-1]]
    
print(result)

Verdicts: Runtime Error

Accepted
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 = sum(list(map(int, input().split())))
c = list(map(int, input().split()))
for i in range(n-1):
  if a[i+1] == a[i] + 1:
    b += c[i]
print(b)

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


Verdicts: Wrong Answer

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

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

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

ans = sum(B)
for i in range(N-1):
  if A[i]+1 == A[i+1]:
    ans += C[A[i]-1]
print(ans)

Verdicts: Wrong Answer

Runtime Error

Accepted
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())
listA = list(map(int,input().split()))
listB = list(map(int,input().split()))
listC = list(map(int,input().split()))

listD = [ListA,ListB,ListC]
sorted(listD)
print(sum(listD[1])+sum(list[2]))


N=int(input())
listA = list(map(int,input().split()))
listB = list(map(int,input().split()))
listC = list(map(int,input().split()))

listD = [ListA,ListB]
sorted(listD)
print(sum(listD[1]))

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

Verdicts: Runtime Error

Runtime Error

Accepted
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(int, input().split())
B = list(int, input().split())
C = list(int, input().split())
happiness = 0
memory = 100
for i in range(N):
  happiness += B[A[i]]
  if memory + 1 == A[i]:
    happiness += C[A[i]]
  memory = A[i]
print(happiness)

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
happiness = 0
memory = 100
for i in range(N):
  happiness += B[A[i]]
  if memory + 1 == A[i]:
    happiness += C[A[i]-1]
  memory = A[i]
print(happiness)

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
happiness = 0
memory = 100
for i in range(N):
  happiness += B[A[i]]
  if memory + 1 == A[i]:
    happiness += C[A[i]]
  memory = A[i]
print(happiness)

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

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
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):
def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    b = [int(x) for x in input().split()]
    c = [int(x) for x in input().split()]

    answer = sum(b)
    for i in range(n-1):
        if a[i+1] == a[i]+1:
            print(a[i])
            answer += c[a[i]-1]
    print(answer)


if __name__ == '__main__':
    main()


def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    b = [int(x) for x in input().split()]
    c = [int(x) for x in input().split()]

    answer = sum(b)
    for i in range(n-1):
        if a[i+1] == a[i]+1:
            answer += c[a[i]-1]
    print(answer)


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
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()))

p = 0
for i in range(N):
    p += B[A[i] - 1]
    print("ba", B[A[i] - 1])
    if i > 0 and A[i] - 1 == A[i - 1]:
        p += C[A[i - 1] - 1]
        print("c", C[A[i - 1] - 1])
print(p)

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

p = 0
for i in range(N):
    p += B[A[i] - 1]
    # print("ba", B[A[i] - 1])
    if i > 0 and A[i] - 1 == A[i - 1]:
        p += C[A[i - 1] - 1]
        # print("c", C[A[i - 1] - 1])
print(p)

Verdicts: Wrong Answer

Accepted