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: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split())) #食べた料理（n種類）
b = list(map(int, input().split())) #料理ごとの満足度
c = list(map(int, input().split())) #満足度ボーナス
total = 0
tmp = 0

for i in a:
    total += b[i-1]
    if tmp == i-1:
        total += c[tmp-1]
    tmp = i

print(total)

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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 - 2])

print(sum(Answer))

Submission status: Wrong Answer

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 - 1])

print(sum(Answer))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

cnt1=0
cnt2=0

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

print(cnt1+cnt2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

kotae = 0

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

Submission status: Wrong Answer

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

kotae = 0

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split() #食べた順番
b = input().split() #満足度
c = input().split() #追加満足度

x = 0 #合計満足度
p = 0 #今回食べている料理の番号
j = -1 #一個前に食べた料理の番号

for i in range(n):
  p = int(a[i]) - 1
  x += int(b[p])
  if j + 1 == p:
    x += int(c[j])
  j = p

print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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
ans = 0
for i in A:
  ans += B[i - 1]
  if a == i - 1:
    ans += C[a - 1]
  else:
    pass
  a = i

print(ans)

Submission status: Wrong Answer

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
ans = 0
for i in A:
  ans += B[i - 1]
  if a == i - 1:
    ans += C[a - 1]
  else:
    pass

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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(len(A)):
    if i > 1 and A[i] - A[i-1] == 1:
        ans += (B[A[i]-1] + C[A[i-1]-1])
    else:
        ans += B[A[i]-1]

print(ans)

Submission status: Wrong Answer

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 and i > 1):
        wa += C[i-2]
    prev = A[i]-1
print(wa)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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, dish in enumerate(a):
    ans += b[dish-1]
    if dish-1 != n-1 and i != n-1:
        ans += c[dish-1]

print(ans)

Submission status: Wrong Answer

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, dish in enumerate(a):
    ans += b[dish-1]
    if dish <= n-1 and i != n-1:
        ans += c[dish-1]

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A_list = [int(i) for i in input().split()]
B_list = [int(i) for i in input().split()]
C_list = [int(i) for i in input().split()]

satisfied = 0

for i, a in enumerate(A_list):
  point = B_list[a-1]
  satisfied += point
  
  if i < len(A_list)-1:
    next = A_list[i+1]
  
    if next == a+1:
      satisfied += C_list[i-1]

print(satisfied)

Submission status: Wrong Answer

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

print(answer)

Submission status: Wrong Answer

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

res=0
back=0

for a in A:
	res=res+B[a-1]					#listは０スタート
	if back==a-1 and a!=len(A):		#A内の今考えている変数が前のと同じなら
		res=res+C[back-1]			#listは０スタート
	back=a
    
print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [one-1 for one in list(map(int, input().split()))]
B = list(map(int, input().split()))
C = {str(i)+str(i+1):one for i, one in enumerate(list(map(int, input().split())))}

ans = 0
prev = 'aa'
for one in A:
    ans+=B[one]
    prev = prev[1]+str(one)
    if prev in C:
        ans+=C[prev]
    
print(ans)

Submission status: Wrong Answer

Solution code:
dishes = int(input())
food_list = list(map(int, input().split()))
satisfaction_list = list(map(int, input().split()))
additional_list = list(map(int, input().split()))
count = 0

for i in range(dishes):
    count += satisfaction_list[food_list[i]-1]
    if food_list[i] == dishes or i == dishes - 1:
        pass
    else:
        count += additional_list[food_list[i]-1]
else:
    print(count)

Submission status: Wrong Answer

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)-1):
  if L[i]+1 == L[i+1]:
    c += C[i-1]
print(c)

Submission status: Wrong Answer

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

good = 0
prev = -2
for a in A:
    i = a - 1
    good += B[prev]
    if prev == i-1:
        good += C[prev]
    prev = i

print(good)

Submission status: Wrong Answer

Solution code:
n = int(input())
f = [0]
g = [0]
h = [0]
f.extend(list(map(int,input().split())))
g.extend(list(map(int,input().split())))
h.extend(list(map(int,input().split())))
e=0
d = sum(g)
for i in range(n):
    if f[i]+1 == f[i+1]:
        e += h[i-1]
print(e + d)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
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)
#eat_lstの並びを確認し、iの次にi+1を食べていたらtuika_lstの値を加算

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

Submission status: Wrong Answer

Solution code:
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)
#eat_lstの並びを確認し、iの次にi+1を食べていたらtuika_lstの値を加算

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

Submission status: Wrong Answer

Solution code:
N=int(input())
A=map(int,input().split())
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ANS=0
for a in A:
  if ANS != 0 and len(C) > (a - 1 - 1) and a-2 >= 0:
    #print("aho", C[a-2], B[a-1])
    ANS += C[a-2]
  ANS += B[a-1]
  #print(ANS, a-1, B[a-1])
#print('----')
print(ANS)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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]-1]+B[A[i-1]-1])
 
        else:
            satisfaction+=B[A[i-1]-1]

print(satisfaction)

Submission status: Wrong Answer

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
pre = -1
for i in a:
    score += b[i-1]
    if(i==pre+1):
        score += c[i-2]
        pre=i
print(score)

Submission status: Wrong Answer

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

result = 0
last = -1

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

print(str(result))

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

last = a[-1]
if last != n:
    c.pop(last-1)

print(sum(b) + sum(c))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

manzoku_do = 0
i = 0

manzoku_do = 0
i = 0

print(a)

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

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

Submission status: Wrong Answer

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:
        ans += C[i-1]
    else:
        ans += 0
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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:
        ans += C[i]
print(ans)

Submission status: Wrong Answer

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

pre_index = 0

sum_point = 0
for index in a_list:
    sum_point += b_list[index - 1]
    
    if (index - pre_index == 1):
        sum_point += c_list[pre_index - 1]
    
    pre_index = index

print(sum_point)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

print(ans + sum(b))

Submission status: Wrong Answer

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

i = 0
point = 0
while i < len(A):
    point += B[A[i]-1]
    print(point)
    if i != 0 and A[i-1] + 1 == A[i]:
        point += C[A[i-1]-1]
    i += 1
print(point)

Submission status: Wrong Answer

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

sum = b[a[0]-1]
p = a[0]-1
for i in a[1:]:
    index = i-1
    sum += b[index]
    if p != n-1:
        sum += c[p]
    p = index

print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

manzoku=0
for i in range(n):
    manzoku=manzoku+B[A[i]-1]
    if i!=0 and A[i]==A[i-1]+1:
        manzoku=manzoku+C[i-2]

print(manzoku)

Submission status: Wrong Answer

Solution code:
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, ai in enumerate(a):
    sum += b[ai-1]
    if i+1 >= n:
        break
    if a[i] == a[i+1] -1:
        sum += c[i-1]
    
print(sum)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
C.append(0)
ans = sum(B)+sum(C)-C[A[-1]-1]
print(ans)

Submission status: Wrong Answer

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
count=0
C.append(0)
ans = sum(B)+sum(C)-C[A[-1]-1]
print(ans)

Submission status: Wrong Answer

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
count=0
for i in A:
    j = i-1
    count+=1
    if (j == N-(len(B)-len(C))) or count == N:
        satisfaction += B[j]
    else:
        satisfaction += B[j] + C[j]
print(satisfaction)

Submission status: Wrong Answer

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
count=0
for i in A:
    j = i-1
    count+=1
    print((len(B)-len(C)))
    if (j == N-(len(B)-len(C))) or count == N:
        satisfaction += B[j]
    else:
        satisfaction += B[j] + C[j]
print(satisfaction)

Submission status: Wrong Answer

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
count=0
for i in A:
    j = i-1
    count+=1
    if i == N or count == N:
        satisfaction += B[j]
    else:
        satisfaction += B[j] + C[j]
print(satisfaction)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

#単入力
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()]


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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

#単入力
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()]


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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-1]
    i += 1
print(manzoku)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sum = sum(c) + sum(b) 

if a[n-1] != n:
    sum -= c[a[n-1]-1]

print(sum)

Submission status: Wrong Answer

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


print(sum)

Submission status: Wrong Answer

Solution code:
N = input()
array_A = list(map(int, input().split()))
array_B = list(map(int, input().split()))
array_C = list(map(int, input().split()))

#print(N)
#print(array_A)
#print(array_B)
#print(array_C)

bonus = []
for i in range(len(array_A)-1):
  if array_A[i] + 1 == array_A[i+1]:
    bonus += [i]

# print(bonus)

bonus_point = 0
for i in (bonus):
  bonus_point += array_C[i-1]

#print(bonus_point)  
score = sum(array_B) + bonus_point
print(score)

Submission status: Wrong Answer

Solution code:
N = input()
array_A = list(map(int, input().split()))
array_B = list(map(int, input().split()))
array_C = list(map(int, input().split()))

#print(N)
#print(array_A)
#print(array_B)
#print(array_C)

bonus = []
for i in range(len(array_A)-1):
  if array_A[i] + 1 == array_A[i+1]:
    bonus += [i]

#print(bonus)

bonus_point = 0
for i in (bonus):
  bonus_point += array_C[i]

#print(bonus_point)  
score = sum(array_B) + bonus_point
print(score)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
add = 0
c_sum = 0
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 < n-1:
        if A[i] + 1 == A[i+1]:
            add +=1

if add-1 == 0:
    c_sum+=C[0]
else:
    for j in range(add -1):
        c_sum+=C[j]
    

b_sum = sum(B)
x_sum = b_sum+c_sum
print(x_sum)