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

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

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

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-1):
  if A[i] == A[i+1]-1 :
    X += (B[i]+C[i+1])
  else:
    X += B[i]
X += B[N-1]  
print(X)

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] == A[i+1]-1 :
    X += (B[i]+C[i+1])
  else:
    X += B[i]
    break
X += B[N-1]  
print(X)

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

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

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

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


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):
a = int(input())
List_a=list(map(int,input().split()))
List_b=list(map(int,input().split()))
List_c=list(map(int,input().split()))
B = 0
C = 0
count = 0
key = 0
for i in List_a:
  B += List_b[i-1]
  if count > 0 and key + 1 ==i:
    C += List_c[i-1]
  key = i

a = int(input())
List_a=list(map(int,input().split()))
List_b=list(map(int,input().split()))
List_c=list(map(int,input().split()))
B = 0
C = 0
count = 0
key = 0
for i in List_a:
  B += List_b[i-1]
  if count > 0 and key+1 ==i:
    C += List_c[i-2]
  key = i
  count += 1
 print(B+C)

a = int(input())
List_a=list(map(int,input().split()))
List_b=list(map(int,input().split()))
List_c=list(map(int,input().split()))
B = 0
count = 0
key = 0
for i in List_a:
  B += List_b[i-1]
  if count > 0 and key+1 ==i:
    B += List_c[i-2]
  key = i
  count += 1
  print(B)

a = int(input())
List_a=list(map(int,input().split()))
List_b=list(map(int,input().split()))
List_c=list(map(int,input().split()))
B = 0
count = 0
key = 0
for i in List_a:
  B += List_b[i-1]
  if count > 0 and key+1 ==i:
    B += List_c[i-2]
  key = i
  count += 1
  print(B)

a = int(input())
List_a=list(map(int,input().split()))
List_b=list(map(int,input().split()))
List_c=list(map(int,input().split()))
B = 0
C = 0
count = 0
key = 0
for i in List_a:
  B += List_b[i-1]
  if count > 0 and key+1 ==i:
    C += List_c[i-2]
  key = i
  count += 1
  print(B+C)

a = int(input())
List_a=list(map(int,input().split()))
List_b=list(map(int,input().split()))
List_c=list(map(int,input().split()))
B = 0
count = 0
key = 0
for i in List_a:
  B += List_b[i-1]
  if count > 0 and key+1 ==i:
    B += List_c[i-2]
  key = i
  count += 1
 
print(B)

Verdicts: Wrong Answer

Runtime Error

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):
i = int(input())

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

res = sum(b)

for j in range(1,i):
    res += b[a[j]-1]
    if a[j] - a[j-1] == 1:
        res += c[a[j-1]-1]
print(res)

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

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

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(0,n-1):
  if a[i]=a[i+1]:
    x+=int(c[int(a[i])-1])
y=sum(b)
print(x+y)


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(0,n-1):
  if a[i]=a[i+1]:
    x+=c[a[i]-1]
y=sum(b)
print(x+y)

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(0,n-1):
  if a[i]+1==a[i+1]:
    x+=c[a[i]-1]
y=sum(b)
print(x+y)

Verdicts: Wrong Answer

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 k in range(N-1):
    if A[k+1] == A[k]+1:
        print(A[k])
        ans += C[A[k]-1]
print(ans)


import sys
sys.setrecursionlimit(500000)
def input():
    return sys.stdin.readline()[:-1]

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 k in range(N-1):
    if A[k+1] == A[k]+1:
        ans += C[A[k]-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()))
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]


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: 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
from io import StringIO
import unittest

def resolve():
    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 + 1] - a[i] == 1:
            ans += c[a[i] - 1]

    print(ans)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3
3 1 2
2 5 4
3 6"""
        output = """14"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """4
2 3 4 1
13 5 8 24
45 9 15"""
        output = """74"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """2
1 2
50 50
50"""
        output = """150"""
        self.assertIO(input, output)

if __name__ == "__main__":
    unittest.main()
    resolve()

import sys
from io import StringIO
import unittest

def resolve():
    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 + 1] - a[i] == 1:
            ans += c[a[i] - 1]

    print(ans)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3
3 1 2
2 5 4
3 6"""
        output = """14"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """4
2 3 4 1
13 5 8 24
45 9 15"""
        output = """74"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """2
1 2
50 50
50"""
        output = """150"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

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

addans=0

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

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

addans=0

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

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

addans=0

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

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

addans=0

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

Verdicts: Runtime Error

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=input().split()
b=input().split()
c=input().split()
ans=0
print(a)

for x in range(len(b)):
  ans+=int(b[x])
  if x+1<len(b):
    if int(a[x])+1==int(a[x+1]):
      ans+=int(c[x])
print(ans)

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

for x in range(len(b)):
  ans+=int(b[x])
  if x+1<len(b):
    if int(b[x])+1==int(b[x+1]):
      ans+=int(c[x])
print(ans)



n=int(input())
a=input().split()
b=input().split()
c=input().split()
ans=0
print(a)

for x in range(len(b)):
  ans+=int(b[x])
  if x+1<len(b):
    if int(a[x])+1==int(a[x+1]):
      ans+=int(c[int(a[x])-1])
print(ans)



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

for x in range(len(b)):
  ans+=int(b[x])
  if x+1<len(b):
    if int(a[x])+1==int(a[x+1]):
      ans+=int(c[int(a[x])-1])
print(ans)



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


n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
count=0
ans=0
for i in range(n):
    ans+=b[a[i]-1]
    if count!=n-1:
        if a[count]+1==a[count+1]:
            ans+=c[a[count]-1]
    count+=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()))
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:
        res += 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(N-1):
    if A[i+1] - A[i] ==1:
        res += 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:
        res += 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(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: Runtime Error

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):
a,b = map(int, input().split())
n = 1
if b == 1:
    print(0)
else:
    while a*n-(n-1) < b:
        n += 1
    print(n)


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(n):
    total += b[a[i] - 1]
    if i < n-1:
        if a[i] + 1 == a[i+1]:
            total += c[a[i]-1]
print(total)

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

print(ans)

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):
t = 0
lis = list()
for i in A:
    lis.append(B[i-1])
    #print(i,t)
    if i == t + 1:
        lis.append(C[i-2])
    t = i

print(sum(lis))

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

t = 1000000000
lis = list()
for i in A:
    lis.append(B[i-1])
    #print(i,t)
    if i == t + 1:
        lis.append(C[i-2])
    t = i

print(sum(lis))

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( )))
print(A)
print(B)
print(C)
total = 0
pos = 0
while pos< N:
	posB = A[pos] -1
	total = total + B[posB]
	if A[pos] - A[pos - 1] == 1 and pos > 0:
		posC = A[pos] - 2
		total = total + C[posC]
	pos += 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
pos = 0
while pos < len(A):
	total = total + B[A[pos] - 1]
	if A[pos + 1] - A[pos] = 1:
		total = total + C[A[pos+1] - 2]
	pos += 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
pos = 0
while pos < N:
  total += B[A[pos] - 1]
  if A[pos + 1] - A[pos] == 1:
    total += C[A[pos + 1] - 2]
  pos += 1
print(total)
   


N = int(input())
A = list(map(int, input().split( )))
B = list(map(int, input().split( )))
C = list(map(int, input().split( )))
print(A)
print(B)
print(C)
total = 0
pos = 0
while pos< N:
	posB = A[pos] -1
	total = total + B[posB]
	if A[pos] - A[pos - 1] == 1 and pos > 0:
		posC = A[pos] - 2
		total = total + C[posC]
	pos += 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
pos = 0
while pos < N:
  total = total + B[A[pos] - 1]
  if A[pos + 1] - A[pos] == 1:
    total = total + C[A[pos + 1] - 2]
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
pos = 0
while pos < N:
	posB = A[pos] -1
	total = total + B[posB]
	if A[pos + 1] - A[pos] == 1:
		posC = A[pos + 1] - 2
		total = total + C[posC]
	pos += 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
pos = 0
while pos< N:
	posB = A[pos] -1
	total = total + B[posB]
	if A[pos] - A[pos - 1] == 1 and pos > 0:
		posC = A[pos] - 2
		total = total + C[posC]
	pos += 1
print(total)


Verdicts: Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

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

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

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

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

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

Verdicts: Runtime Error

Runtime Error

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

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


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

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


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

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


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):
    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(N-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 = input()

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

satisfaction = 0
for i in a:
  satisfaction += b[ i ]
  if i > 0:
    if a[ i ] == a[ i - 1 ] + 1:
    satisfaction += c[ i ]
print( satisfaction )

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

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()))
b_dic = {}
for i in range(1, N + 1):
  b_dic[i] = B[i - 1]
c_dic = {}
for i in range(1, N):
  c_dic[i] = C[i - 1]
count=0
br = -1
for a in A:
  count += B[a]
  if br == a - 1:
    count += C[br]
  br = a
print(count)

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
b_dic = {}
for i in range(1, N + 1):
  b_dic[i] = B[i - 1]
c_dic = {}
for i in range(1, N):
  c_dic[i] = C[i - 1]
count=0
br = -1
for a in A:
  count += b_dic[a]
  if br == a - 1:
    count += c_dic[br]
  br = a
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())
d = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

s = sum(b)

for i in range(n-1):
  if d[i+1]-d[i] == 1:
    s += c[i]
    
print(s)
        

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

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

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

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

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

# j=0

#   s+=b[a[i]-1]
#   # print(a[i])
#   try:
#     if (a[i+1]-a[i])==1 and (i)<(n-1):
#       s+=c[j]
#       j+=1
#         # print(c[j],a[i],a[i-1])
#   except:

# print(s)
ss=sum(b)+sum(c)
print(ss)

n = int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
# c.sort()
s = 0
j=0
for i in range(n):
  s+=b[a[i]-1]
  # print(a[i])
  try:
    if (a[i+1]-a[i])==1:
      s+=c[a[i]-1]
      j+=1
        # print(c[j],a[i],a[i-1])
  except:
    pass
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()))

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 = 0

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

ans = 0
before_i = 100
for i in an:
    ans += bn[i-1]
    print(bn[i-1])
    if (i-before_i) == 1:
        ans += cn[before_i-1]
        print(cn[before_i -1])
    before_i = i
print(ans)

n = int(input())
an = list(map(int, input().split()))
bn = list(map(int, input().split()))
cn = list(map(int, input().split()))

ans = 0
before_i = 100
for i in an:
    ans += bn[i-1]
    if (i-before_i) == 1:
        ans += cn[before_i-1]
    before_i = 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()))

ans = 0
memo = -100
for i in range(N):
  dish = A[i]
  base = B[dish - 1]
  ans += base
  if i - memo == 1:
    ans += C[memo]
  memo = 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
memo = -100
for i in range(N):
  dish = A[i]
  base = B[dish - 1]
  ans += base
  if dish - memo == 1:
    ans += C[dish - 2]
  memo = dish
  
    
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 = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

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

man = sum(B)

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

print(man)

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

man = sum(B)

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

print(man)

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

def main():
    n=int(input())
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))
    C=list(map(int,input().split()))
    
    sum=0
    for i in range(n):
        sum+=B[A[i]-1]
        if i!=0:
            dif=abs(A[i]-A[i-1])
            if dif==1:
                index=min(A[i],A[i-1])-1
                sum+=C[index]
    print(sum,end="")



if __name__ == '__main__':
    main()  

import numpy as np

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

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

    print(s)




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 = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
ans = 0
prev = -1
for i in range(n):
  ans += b[a[i]-1]
  if a[i] == prev + 1:
    ans += c[prev]
  tmp = a[i]
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 = 0
prev = -100
for i in range(n):
  ans += b[a[i]-1]

  if a[i] == (prev + 1):
    ans += c[prev-1]

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

a.append(23)

count = 0

for i in range(n):
    count += b[a[i]-1]
    print("added"+str(b[a[i]-1]))
    if ((a[i]+1)==a[i+1]):
        print("yeah"+str(c[i]))
        count += c[i+1]
print(count)



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

a.append(23)

count = 0
print("dsadsd")
for i in range(n):
    count += b[a[i]-1]
    print("added"+str(b[a[i]-1]))
    if ((a[i]+1)==a[i+1]):
        print("yeah"+str(c[i]))
        count += c[i-1]
print(count)



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

a.append(23)

count = 0

for i in range(n):
    count += b[a[i]-1]
    #print("added"+str(b[a[i]-1]))
    if ((a[i]+1)==a[i+1]):
        #print("yeah"+str(c[i]))
        count += c[i+1]
print(count)




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

a.append(23)
c.append(0)
count = 0

for i in range(n):
    count += b[a[i]-1]
    #print("added"+str(b[a[i]-1]))
    if ((a[i]+1)==a[i+1]):
        #print("yeah"+str(c[a[i]-1]))
        count += c[a[i]-1]
print(count)



Verdicts: Runtime Error

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

res = sum(manzoku_lst)


for i in range(n-1):
    if eat_lst[i] == eat_lst[i+1] - 1:
        res = tuika_lst[i] + res
print(res)


n = int(input())
eat_lst = list(map(int,input().split()))
manzoku_lst = list(map(int,input().split()))
tuika_lst = list(map(int,input().split()))

res = sum(manzoku_lst)


for i in range(n-1):
    if eat_lst[i] + 1 == eat_lst[i+1]:
        res = tuika_lst[i] + res
print(res)


n = int(input())
eat_lst = list(map(int,input().split()))
manzoku_lst = list(map(int,input().split()))
tuika_lst = list(map(int,input().split()))

res = sum(manzoku_lst)


for i in range(n-1):
    if eat_lst[i] + 1 == eat_lst[i+1]:
        res = tuika_lst[eat_lst[i]-1] + res
print(res)


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

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


import math

def resolve():
    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>=1):
            if(A[i]==A[i-1]+1):
                ans+=C[A[i-1]-1]
        
    print(ans)
  

resolve()


Verdicts: Runtime Error

Wrong Answer

Runtime Error

Accepted