Problem:


Score : 200 points

Problem Statement

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.

Constraints

All values in input are integers.

2 \leq N \leq 20

1 \leq A_i \leq N

A_1, A_2, ..., A_N are all different.

1 \leq B_i \leq 50

1 \leq C_i \leq 50

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 ... A_N
B_1 B_2 ... B_N
C_1 C_2 ... C_{N-1}

Output

Print the sum of the satisfaction points Takahashi gained, as an integer.

Sample Input 1

3
3 1 2
2 5 4
3 6

Sample Output 1

14

Takahashi gained 14 satisfaction points in total, as follows:

First, he ate Dish 3 and gained 4 satisfaction points.

Next, he ate Dish 1 and gained 2 satisfaction points.

Lastly, he ate Dish 2 and gained 5 + 3 = 8 satisfaction points.

Sample Input 2

4
2 3 4 1
13 5 8 24
45 9 15

Sample Output 2

74

Sample Input 3

2
1 2
50 50
50

Sample Output 3

150



Sample input:
3
3 1 2
2 5 4
3 6


Sample output:
14

Submission status: Runtime Error

Solution code:
N = int(input())
A = input().split()
B = input().split()
C = input().split()
for i in range(len(A)):
    A[i] = int(A[i])
    B[i] = int(B[i])
for i in range(len(C)):
    C[i] = int(C[i])
ans = 0
for i in range(N):
    if A[i - 1] < A[i]:
        ans += B[A[i]] + C[i];
    else:
        ans += B[A[i]];
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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()]

s = 0
pre_food = A[0]
for food in A:
    s += B[food]
    if food - pre_food == 1 : s += C[food]
    pre_food = food

print(s)

Submission status: Runtime Error

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

def tarou(n,a,b,c):
	manzoku = b[a[0]-1]
	for i in range (1,n):
		manzoku += b[a[i]-1]
		if a[i]-a[i-1] == 1:
				manzoku += c[i]
	print (manzoku)
tarou (n,a,b,c)

Submission status: Runtime Error

Solution code:
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):
    val = a[i]-1
    ans += b[val]
    if a[i+1] == a[i]+1:
        ans += c[i-1]
        
print(ans)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
C=list(map(int, input().split()))
a=0
for co,i in enumerate(A[):
    a+=B[i-1]
    if co>=1 :
        if A[co-1]!=N:
            a+=C[A[co-1]-1]
print(a)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
score = 0
num = 0

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
N = int(input())

A_list = list(input().split())
A_list_int = [int(s) for s in A_list]

B_list = list(input().split())
B_list_int = [int(s) for s in B_list]

C_list = list(input().split())
C_list_int = [int(s) for s in C_list]

Answer = []

for i in range(0, N):
  Answer.append(B_list_int[A_list_int[i] - 1])
  if i != N and i != 0:
      if A_list_int[i - 1] == A_list_int[i] - 1:
          Answer.append(C_list_int[i])

print(sum(Answer))

Submission status: Runtime Error

Solution code:
N = int(input())
As = map(int,input().split())
Bs = map(int,input().split())
Cs = map(int,input().split())

score = 0
for i in range(N):
  score += Bs[As[i]]
  if i >= 1 and As[i]==As[i-1]+1:
    score += Cs[As[i]]
print(score)

Submission status: Runtime Error

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

ans = 0
bf = 0
af = 0
cnt_list = []
for i, order in enumerate(a):
    if i == 0:
        bf = order
    af = order
    if af - bf == 1:
        cnt_list.append(i)
    bf = order

for i in cnt_list:
    ans += int(c[i])

print(ans + sum(b))

Submission status: Runtime Error

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

bf = 0
af = 0
cnt_list = []
for i, order in enumerate(a):
    if i == 0:
        bf = order
    af = order
    if af - bf == 1:
        cnt_list.append(i)

print(sum(b)+c[sum(cnt_list)])

Submission status: Runtime Error

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

ans = 0
prev = 0
for i in range(n):
  if a_list[i] == prev + 1:
    ans += b_list[i] + c_list[i]
  else:
    ans += b_list[i]
  prev = a_list[i]
print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding:utf8 -*-

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

Submission status: Runtime Error

Solution code:
# -*- coding:utf8 -*-

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

Submission status: Runtime Error

Solution code:
# -*- coding:utf8 -*-

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

answer = sum(B)
for i in range(len(B)):
  if B[i+1] = B[i]+1:
    answer += C[i]

print(answer)

Submission status: Runtime Error

Solution code:
a,b = map(int, input().split())
n = 1
if b == 1:
    print(0)
else:
    while a*n-(n-1) < b:
        n += 1
    print(n)

Submission status: Runtime Error

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

total = sum(b)
last_dish = a[0]
for d in a[1:]:
	if d-last_dish == 1:
    	total += c[last_dish-1]
	last_dish = d
print(total)

Submission status: Runtime Error

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

ans=0

for x,y in zip(a,a[1:]):
  if y == x+1:
    ans += c[x-1]
    
print(sum(y)+ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
#input
N = int(input())
A = list(map(int, input()))
B = list(map(int, input()))
C = list(map(int, input()))

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

Submission status: Runtime Error

Solution code:
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(0,n):
    ans += b[a[i]-1]
    if i != 0 and a[i-1]+1 == a[i]:
        ans += c[a[i]-1]
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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):
  point += B[A[i]]
  if i>0 and A[i] == A[i-1]:
    point += C[A[i-1]]
print(point)

Submission status: Runtime Error

Solution code:
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):
  point += B[A[i]]
  if i>0 and A[i] = A[i-1]:
    point += C[A[i-1]]
print(point)

Submission status: Runtime Error

Solution code:
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):
  count+= B[A[i]]
  if i>0 and A[i] = A[i-1]:
    count += C[A[i-1]]
print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
sumB=sum(B)
l_A=x for x in A if x+1=x[1:]
print(N)

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
sumB=sum(B)
l_A=x for x in A if x+1=x[1:]
l_C=y-1 for y in l_A
realC=C[l_C]
sumC=sum(realC)
sum=sumB+sumC
print(sum)

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split())
B=list(map(int,input().split())
C=list(map(int,input().split())
print(N)

Submission status: Runtime Error

Solution code:
N=int(input())
A=int(x) for x in input().split()
B=int(y) for y in input().split()
C=int(z) for z in input().split()
print(N)

Submission status: Runtime Error

Solution code:
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()
print(N)

Submission status: Runtime Error

Solution code:
N=int(input())
A=(int(x) for x in list().split())
B=(int(x) for x in list().split())
C=(int(x) for x in list().split())
sumB=sum(B)
sumC=sum(C)
print({}.format(sumB+sumC))

Submission status: Runtime Error

Solution code:
N=int(input())
A=(int(x) for x in list().split())
B=(int(x) for x in list().split())
C=(int(x) for x in list().split())
sumB=sum(B)
sumC=sum(C)
print(sumB+sumC)

Submission status: Runtime Error

Solution code:
N=int(input())
A=(int(x) for x in list().split())
B=(int(x) for x in list().split())
C=(int(x) for x in list().split())
sumB=sum(B)
#Aにおいてnが[n:n+1]+1=[n+1:n+2]ならばそのようなnをlist化する
#list化されたnのみCで抽出してそれを足す
l_number=[i for i in A if i+1=i[1:]]
l_number2=C[l_number-1]
sumC=sum(l_number2)
print(sumB+sumC)

Submission status: Runtime Error

Solution code:
N=int(input())
A=list().split()
B=list().split()
C=list().split()
sumB=sum(B)
sumC=sum(C)
print(sumB+sumC)

Submission status: Runtime Error

Solution code:
N=int(input())
A=list().split()
B=list().split()
C=list().split()
sumB=sum(B)
l_number=B
l_number2=C[l_number-1]
sumC=sum(l_number2)
print(sumB+sumC)

Submission status: Runtime Error

Solution code:
N=int(input())
A=list().split()
B=list().split()
C=list().split()
sumB=sum(B)
l_number= i for i in A if i+1=i[1:]
l_number2=C[l_number-1]
sumC=sum(l_number2)
print(sumB+sumC)

Submission status: Runtime Error

Solution code:
N=int(input())
A=list().split()
B=list().split()
C=list().split()
sumB=sum(B)
#Aにおいてnが[n:n+1]+1=[n+1:n+2]ならばそのようなnをlist化する
#list化されたnのみCで抽出してそれを足す
l_number=[i for i in A if i+1=i[1:]]
l_number2=C[l_number-1]
sumC=sum(l_number2)
print(sumB+sumC)

Submission status: Runtime Error

Solution code:
A,B = map(int,input().split())

if A >= B:
  print(1)
  
else:
 
  for i in list(range(1,21)):
    if (A-1) * i + A >= B:
      print(i+1)
      break

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(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(N):
    if  i>=1:
        if  A[i-1]+1==A[i]:
            satisfaction+=(C[A[i]-1]+B[A[i]-1])
 
        else:
            satisfaction+=B[i]

print(satisfaction)

Submission status: Runtime Error

Solution code:
N=int(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(N-1):
    if  i>=1:
        if  A[i-1]+1==A[i]:
            satisfaction+=C[A[i]-1]+B[A[i]-1]
 
        else:
            satisfaction+=B[i]

print(satisfaction)

Submission status: Runtime Error

Solution code:
N=int(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(N-1):
    if  A[i]+1==A[i+1]:
        satisfaction+=C[A[i]]+B[i]
 
    
    else:
        satisfaction+=B[i]

print(satisfaction)

Submission status: Runtime Error

Solution code:
N=int(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(N-1)
    if  A[i]+1==A[i+1]:
        satisfaction+=C[A[i]]+B[i]
 
    
    else:
        satisfaction+=B[i]

print(satisfaction)

Submission status: Runtime Error

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))    
    score = 0
    pre = -1
    for i in a:
        score += b[i]
        if(i==pre+1):
            score += c[i-2]
            pre=i
    print(score)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))    
    score = 0
    pre = -1
    for i in a:
        score += b[i]
        if(i==pre+1):
            score += c[i-2]
            pre =i
    print(score)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def main():
    n = int(input())
    a = int(input().split())
    b = int(input().split())
    c = int(input().split())
    score = 0
    for i in range(n):
        score += b[a[i]]
        if a[i+1] - a[i] == 1:
            score += c[a[i]-1]
    print(score)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def main():
    n = int(input())
    a = input().split()
    b = input().split()
    c = input().split()
    score = 0
    for i in range(n):
        score += a[i]
        if a[i+1] - a[i] == 1:
            score += b[i]
    print(score)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

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

def buffet(N,x,y,z):
  a = sum(y)
  for i in range(N-1):
    if x[i+1] - x[i] == 1:
      a = a + z[i+1]
  print(a)

if __name__ == '__main__':
  buffet(N,A,B,C)

Submission status: Runtime Error

Solution code:
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(len(B)):
    co+=B[i]
for j in range(len(C)):
    if A[j+1]==A[j]+1:
        co+=C[A[j]]
print(co)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [*map(int, input().split())]
b = [*map(int, input().split())]
c = [*map(int, input().split())]

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

Submission status: Runtime Error

Solution code:
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:
    print(sum(b) + sum(c))
else:
    print(sum(b) + sum(c) - c[a[n - 1] - 1])

Submission status: Runtime Error

Solution code:
n = int(input())
a = input().split()
b = input().split()
c = input().split()

manzoku_do = 0
i = 0

manzoku_do += int(b[int(a[i])])
i += 1

while i < n:
  manzoku_do += int(b[int(a[i])])
  
  if int(a[i - 1]) == int(a[i]) - 1:
    manzoku_do += int(c[int(a[i -1])])
    i += 1
    
print(manzoku_do)

Submission status: Runtime Error

Solution code:
n = int(input())
a = input().split()
b = input().split()
c = input().split()

manzoku_do = 0
i = 0

manzoku_do += int(b[int(a[i])])
i += 1

while i < n:
  manzoku_do += int(b[int(a[i])])
  
  if a[i - 1] == a[i] - 1:
    manzoku_do += int(c[int(a[i -1])])
    i += 1
    
print(manzoku_do)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
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))

Submission status: Runtime Error

Solution code:
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))

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    n=int(input())
    *a,=map(int,input().split())
    *b,=map(int,input().split())
    *c,=map(int,input().split())
    t=sum(b)
    for i in range(len(a)-1):
        if a[i]+1==a[i+1]:
            t+=c[i+1]
    print(t)

            
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n = int(input())
a = map(int, input().split())
b = map(int, input().split())
c = map(int, input().split())

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

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

ans = 0
store = -5
for e, i in enumerate(a):
    bi = b[(e+2)%3]
    if i == store + 1:
        print(e)
        ans += c[i-2]
    ans += bi
    store = i
print(ans)

Submission status: Runtime Error

Solution code:
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):
    m += B[a[i] - 1]
for t in range(N-1):
    if A[t] + 1 == A[t + 1]:
        m += C[A[t] - 1]
print(m)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
m = sum(B)
for t in range(N-1):
    if a[t] + 1 == a[t + 1]:
        m += C[a[t] - 1]
print(m)

Submission status: Runtime Error

Solution code:
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):
    m += B[a[i] - 1]
for t in range(N-1):
    if a[t] + 1 == a[t + 1]:
        m += C[a[t] - 1]
print(m)

Submission status: Runtime Error

Solution code:
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):
    m += B[a[i] - 1]
for i in range(N-1):
    if a[i] + 1 == a[i + 1]:
        m += C[a[i] - 1]
print(m)

Submission status: Runtime Error

Solution code:
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):
    m +=B[a[i] - 1]
for i in range(N-1):
    if a[i] + 1 == a[i + 1]:
        m +=C[a[i] - 1]
print(m)

Submission status: Runtime Error

Solution code:
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):
    m +=B[a[i] -1]
for i in range(N-1):
    if a[i] + 1 == a[i + 1]:
        m +=C[a[i] - 1]
print(m)

Submission status: Runtime Error

Solution code:
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):
    m +=B[a[i] -1]
for i in range(N-1):
    if a[i] + 1 == a[i + 1]:
        m + =C[a[i] - 1]
print(m)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
manzoku = sum(B)
i = 1
while N>i-1:
    if A[i]-A[i-1] == 1:
        manzoku += C[i-1]
    i += 1
print(manzoku)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
manzoku = sum(B)
i = 1
while N>i:
    if A[i]-A[i-1] == 1:
        manzoku += C[i]
    i += 1
print(manzoku)