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

    
print(sum(B)+bonus)

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

    
print(sum(B)+bonus)

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()))
tot = sum(B)
for i in range(n-1):
  if A[i+1] == A[i]+1:
    tot += C[A[i]]
print(tot)

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

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

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 = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

score = 0

for val in b_list :
	score +=val
	
for val in range(n-1):
	if a_list[val+1] - a_list[val] == 1:
		score += c_list[a_list[val-1]]
	else:
		pass

print(score)


n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

score = 0

for val in b_list :
	score +=val
	
for val in range(n):
	if a_list[val+1] - a_list[val] == 1:
		score += c_list[val]
	else:
		pass

print(score)

n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

score = 0

for val in b_list :
	score +=val
	
for val in range(n-1):
	if a_list[val+1] - a_list[val] == 1:
		score += c_list[a_list[val-1]]
	else:
		pass

print(score)

n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

score = 0

for val in b_list :
	score +=val
	
for val in range(n-1):
	if a_list[val+1] - a_list[val] == 1:
		score += c_list[a_list[val]-1]
	else:
		pass

print(score)

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):
N=int(input())
Alist=list(map(int,input().split()))
Blist=list(map(int,input().split()))
Clist=list(map(int,input().split()))

Cplus=0
for n in range (1,N-1):
  if Alist[n]-Alist[n-1] == 1:
    Cplus += Clist[Alist[n-1]-1]



print(sum(Blist)+Cplus)

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

bonus=0

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

print(sum(B)+bonus)

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


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

bonus=0
for x in range(1,n):
  if A[x-1]+1 == A[x]:
    bonus += C[x-1]

ans = sum(B) + bonus
print(ans)

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

bonus=0
for x in range(0,n):
  if A[x] == A[x+1] +1:
    bonus += C[x]

ans = sum(B) + bonus
print(ans)

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
bonus=0
for x in range(1,n):
  if A[x-1]+1 == A[x]:
    bonus += C[A[x]-2]
 
ans = sum(B) + bonus
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())
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(len(a)-1):
  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 = sum(b)
for i in range(len(a)-1):
  if(a[i+1] == a[i] + 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 = sum(map(int,input().split()))
c = kist(map(int,input().split()))
for i in range(n-1):
  if a[i+1] == a[i] + 1:
    b += a[i+1]
print(b)
  

n=int(input())
a=list(map(int,input().split()))
b=sum(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: 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()))


def solve():
    point = 0

    index = 1
    for AA in A:
        point += B[AA - 1]
        if index != 1 and len(C) > index - 1:
            point += C[index - 1]

        index += 1

    return point


print(solve())


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


def solve():
    point = 0

    point += sum(B)

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

    return point


print(solve())


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

print(co

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

print(co)

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

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

print(ans)

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

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

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

n = int(input())

a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i 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: 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()))
   
if N == 2:
    if A[1] == 2:
        print(sum(B)+sum(C))
    else:
        print(sum(B))
else:
    k = A[-1]
    if k == A[N-1]:
        print(sum(B)+sum(C))
    else:
        print(sum(B)+sum(C)-C[k-1])

if N == 2:
    if A[1] == 2:
        print(sum(B)+sum(C))
    else:
        print(sum(B))
else:
    k = A[-1]
    if k == A[N-1]:
        print(sum(B)+sum(C))
    else:
        print(sum(B)+sum(C)-C[k-1])

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):
    k = A[i]
    ans += B[k-1]
    if i < N-1:
        if A[i+1] == k+1 and k != N:
            ans += C[k-1]
        else:
            pass
    else:
        pass
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())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

bounas = 0

B_Sum = sum(B)

for x in A:
    if x == x+1:
        bounas += C[x-1]
        
print((bounas) + (B_Sum) )

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







cnt = 0


temp = ""


for x in A:
    
    
    cnt += B[x-1]
    
    
    if temp == x - 1:
        cnt += C[temp-1]
        
    
    temp = x

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 = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
C = list(map(int, input().split(' ')))
m = 0
pre = -1
for a in A:
    m += B[a-1]
    if a - pre == 1
        m += C[pre-1]
    pre = a
print(m)

L = [int(input()), list(map(int, input().split(' '))), list(map(int, input().split(' '))), list(map(int, input().split(' ')))]
print(sum([L[2][L[1][i]-1]+L[3][L[1][i]-2] if i>0 and L[1][i]-L[1][i-1]==1 else L[2][L[1][i]-1] for i in range(L[0])]))

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

count = 0
for j in A:
    count += B[j-1]

#print(count)

for z in range(N-1):
    if A[z+1]- A[z] == 1:
        zz = A[z]
        count += C[zz-1]

#print(count)
    
    

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

count = 0
for j in A:
    count += B[j-1]

#print(count)

for z in range(N-1):
    if A[z+1]- A[z] == 1:
        zz = A[z]
        count += C[zz-1]

print(count)
    
    


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

m=0

at0
for i,ai in enumerate(a):
    m+=b[ai-1]
    if ai == at+1:
        m+=c[at-1]
    at=ai
print(m)

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

m=0

at=-1
for ai in a:
    m+=b[ai-1]
    if ai == at+1:
        m+=c[at-1]
    at=ai
print(m)


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

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

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

count = 0

for i in range(n):

    if i == 0:
        count += b[a[i]-1]

    else:
        count += b[a[i]-1]

        if a[i] - a[i-1] == 1:
            count += c[a[i-1]-1]

print(count)

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

count = 0

for i in range(n):

    if i == 0:
        count += b[a[i]-1]

    else:
        count += b[a[i]-1]

        if a[i] - a[i-1] == 1:
            count += c[a[i-1]-1]

print(count)

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

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

print(ans)

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

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

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

total = 0;
for i in range(len(a)):
    total += b[a[i] - 1]
    if n - 1 == i: 
        continue
    elif a[i] + 1 == a[i + 1]: 
        print(i)
        total += c[a[i] - 1]

print(total)

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

total = 0;
for i in range(len(a)):
    total += b[a[i] - 1]
    if n - 1 == i: 
        continue
    elif a[i] + 1 == a[i + 1]: 
        total += c[a[i] - 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()))
s = 0
for i in range(n):
  s += b[a[i]]
  if i < n-1 and a[i+1] == a[i]+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(n):
  s += b[a[i]-1]
  if 0 < i  and a[i] == a[i-1]+1:
    s += c[a[i-1]-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())
listA=list(map(int,input().split()))
listB=list(map(int,input().split()))
listC=list(map(int,input().split()))
sumB=int(sum(listB))
print("sumB",sumB)
for i in range(1,N-1):
    if listA[i] == listA[i-1]+1:
        sumB=sumB+int(listC[listA[i-2]])
print(sumB)

N=int(input())
listA=list(map(int,input().split()))
listB=list(map(int,input().split()))
listC=list(map(int,input().split()))
sumB=int(sum(listB))
for i in range(1,N-1):
    if listA[i] == listA[i-1]+1:
        sumB=sumB+int(listC[listA[i-2]])
print(sumB)

N=int(input())
listA=list(map(int,input().split()))
listB=list(map(int,input().split()))
listC=list(map(int,input().split()))
sumB=int(sum(listB))
for i in range(1,N-1):
    if listA[i] == listA[i-1]+1:
        sumB=sumB+int(listC[listA[i-2]])
print(sumB)

N=int(input())
listA=list(map(int,input().split()))
listB=list(map(int,input().split()))
listC=list(map(int,input().split()))
sumB=int(sum(listB))
for i in range(1,N):
    if listA[i] == listA[i-1]+1:
        sumB=sumB+int(listC[listA[i-1]-1])
print(sumB)

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

N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
C=list(map(int, input().split()))
F=0
for  i  in range(N-1):
      if A[i+1]==A[i]+1 and i<N-1:
         a=A[i]
         F+=C[a-1]
print(F+sum(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())
foods = [int(i) for i in input().split()]
eff = sum([int(i) for i in input().split()])
plus = [int(i) for i in input().split()]
if foods[-1]-2 in plus:
  print(eff + plus[foods[-1]-2])
else:
  print(eff)

N = int(input())
foods = [int(i) for i in input().split()]
eff = sum([int(i) for i in input().split()])
plus = [int(i) for i in input().split()]
tmp = 0
for i, f in enumerate(foods):
  if i == 0:
    tmp = f
  elif f - tmp == 1:
    eff += plus[f-2]
    tmp = f
print(eff)

N = int(input())
foods = [int(i) for i in input().split()]
eff = sum([int(i) for i in input().split()])
plus = [int(i) for i in input().split()]
tmp = 0
for i, f in enumerate(foods):
  if i == 0:
    tmp = f
  elif f - tmp == 1:
    eff += plus[f-2]
    tmp = f
  else:
    tmp = f
print(eff)

Verdicts: 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):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
for i in range(n-1):
    if a[i]+1==a[i+1]:
        ans+=c[a[i]-1]
print(sum(b)+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):
    if a[i]+1==a[i+1]:
        ans+=c[a[i]-1]
print(sum(b)+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())
li_a = list(map(int, input().split()))
li_b = list(map(int, input().split()))
li_c = list(map(int, input().split()))
C = 0
for i in range(N-1):
  if li_a[i] == li_a[i+1]:
    C += li_c[i]
B = sum(li_b)
print(B+C)

N = int(input())
li_a = list(map(int, input().split()))
li_b = list(map(int, input().split()))
li_c = list(map(int, input().split()))
C = 0
for i in range(N-1):
  if li_a[i] == li_a[i+1] - 1:
    C += li_c[i]
B = sum(li_b)
print(B+C)

N = int(input())
li_a = list(map(int, input().split()))
li_b = list(map(int, input().split()))
li_c = list(map(int, input().split()))
C = 0
for i in range(N-1):
  if li_a[i] == li_a[i+1] - 1:
    C += li_c[li_a[i]-1]
B = sum(li_b)
print(B+C)

Verdicts: 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):
N=int(input())
Ai = list(map(int,input().split()))
Bi = list(map(int,input().split()))
Ci = list(map(int,input().split()))

ans ~ sum(Bi)

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

print(ans)

N=int(input())
Ai = list(map(int,input().split()))
Bi = list(map(int,input().split()))
Ci = list(map(int,input().split()))

ans = sum(Bi)

for i in range(N-1):
  if Ai[i] + 1 == Ai[i+1]:
    ans += Ci[Ai[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 = [input().split() for l in range(N)]
B = [input().split() for l in range(N)]
C = [input().split() for l in range(N-1)]
ans = 0

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

print(ans)

N = int(input())
A = [input().split() for l in range(N)]
B = [input().split() for l in range(N)]
C = [input().split() for l in range(N-1)]
ans = 0

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

N = int(input())
A = [input().split() for l in range(N)]
B = [input().split() for l in range(N)]
C = [input().split() for l in range(N-1)]
ans = 0

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

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

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

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 = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

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


N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

counter = 0
for i in range(N):
    # print(i)
    num = A[i] - 1
    counter += B[num]
    # print('Add:', B[num])
    if i != 0 and num - 1 == A[i-1] - 1:
        counter += C[num-1]
        # print('Add:', C[num-1])
    # print('')
print(counter)


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

ans = 0

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

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


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


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

N = int(input())
A = []
B = 0
C = []
for i in range(N):
  A[i] = int(input())
for i in range(N):
  B += int(input())
for i in range(N-1):
  C[i] = int(input())
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 = 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.append(C[A[i]-1])
print(sum(B))

Verdicts: 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 = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
cnt = 0
for i in range(N):
    if (cnt > 0) and (a[i]==(a[i-1]+1)):
        cnt += c[i]

    cnt += b[a[i]-1]
    
print(cnt)

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

    cnt += b[a[i]-1]
    
print(cnt)

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

sat = sum(B)
pre_a = A[0]
for a in A[1:]:
  if a == pre_a + 1:
    sat += C[pre_a]
  pre_a = a
  
print(sat)

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

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

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
sat = sum(B)
pre_a = A[0]
for a in A[1:]:
  if a == pre_a + 1:
    sat += C[pre_a-1]
  pre_a = a
  
print(sat)

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

ful = sum(B)

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

print(ful)

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

ful = sum(B)

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

print(ful)


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

ful = sum(B)

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

print(ful)


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):
  if a[i+1]==a[i]+1:
    m=m+c[i]

print(sum(b)+m)

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-1):
  if a[i+1]==a[i]+1:
    m=m+c[i]

print(sum(b)+m)

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-1):
  if a[i+1]==a[i]+1:
    m=m+c[a[i]-1]

print(sum(b)+m)

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):
P=0
P+=B[A[0]-1]
for i in range(N-1):
    if A[i]!=N:
        u=B[A[i+1]-1]
        q=C[A[i+1]-2]
        o=u+q
        P+=o
    else:
        u=B[A[i+1]-1]
        P+=u
    
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
P+=B[A[0]-1]
for i in range(N-1):
    if A[i]!=N and A[i+1]==A[i]+1:
        u=B[A[i+1]-1]
        q=C[A[i+1]-2]
        o=u+q
        P+=o
    else:
        u=B[A[i+1]-1]
        P+=u
    
print(int(P))

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

n=int(input())
a,b,c=[list(map(int,input().split())) for _ in range(3)]
x=sum(b)
for i in range(n-1):
    if a[i]+1==a[i+1]:
        x+=c[a[i]-1]
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()))
 
answer = 0
 
for i in range(N):
  answer = answer + B[i]
  
for i in range(N):
  if i != 0:
    if A[i] == A[i-1]+1:
      answer = answer + C[i-1]
    
print(answer)

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

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

answer = 0

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

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

answer = 0

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

n=int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
c_list = list(map(int,input().split()))
count = 0
for i in range(n):
    index=a_list[i]
    count += b_list[index - 1]
#     print(count)
    if i !=0:
        if a_list[i] == a_list[i-1] + 1:
            count += c_list[a_list[i-1]-1]
print(count)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Accepted