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

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

print(total)

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

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

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

print(sat)

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

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

for i in range(n):
  num = int(a[i])
  m += b[num - 1]
  print(i, m)  #erase later
  if num != n and i != n - 1:
    if num + 1 == int(a[i + 1]):
      m += c[num - 1]
      print('C point', m)  #erase later
print(m)

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

for i in range(n):
  num = int(a[i])
  m += b[num - 1]
  
  if i != n - 1:
    if a[i] == num:
      m += c[i - 1]
    
print(m)

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

for i in range(n):
  num = int(a[i])
  m += b[num - 1]
  
  if i != n - 1:
    if a[i + 1] == num:
      m += c[i]
    
print(m)

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

score = 0

for n in range(N):
    b_index = A[n]-1
    score = score + B[b_index]
    print('score=',score)
    if n -1 != -1:
        if A[n-1]+1 == A[n]:

            score += C[A[n]-2]

print(score)

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

score = 0

for n in range(N):
    a = A[n]
    b_index = a-1
    score = score + B[b_index]

    if b_index -1 > -1:
        if A[n-1] + 1 == a:
            score = score + C[a-2]

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

manzoku=0;

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

manzoku=0;

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))

    sat_sum = 0

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

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

Submission status: Wrong Answer

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

full = 0
pre = 0
for i in range(N):
    a = A[i]
    b = B[a-1]
    if pre+1 == a:
        c = C[pre-1]
    else:
        c = 0

    full += b + c
    pre = a


print(full)

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)
print(sum(B)+sum(C)-C[A[-1]-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
'''
3
3 1 2
2 5 4
3 6
'''
N = int(input())
sp=[int(x) for x in input().split()]
ap=[int(x) for x in input().split()]
an=sum(sp) + sum(ap[:-1])
print(an)

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.insert(0,0)
max=0

for i in range(N):
    max=max+b[a[i]-1]
    max=max+c[a[i]-1]
print(max)

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.insert(0,0)
max=0
print(a,b,c)

for i in range(N):
    max=max+b[a[i]-1]
    max=max+c[a[i]-1]
print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
cook_list = list(map(int,input().split()))
satisfy_list = list(map(int,input().split()))
plus_satisfy_list = list(map(int,input().split()))

sum_point = 0
prev_num = 0

for now_num in cook_list:
  sum_point += satisfy_list[now_num - 1]
  if (now_num - prev_num) == 1 and (now_num != 0):
    sum_point += plus_satisfy_list[prev_num - 1]
  prev_num = now_num
  
print(sum_point)

Submission status: Wrong Answer

Solution code:
N = int(input())
cook_list = list(map(int,input().split()))
satisfy_list = list(map(int,input().split()))
plus_satisfy_list = list(map(int,input().split()))

sum_point = 0
prev_num = 0

for now_num in cook_list:
  sum_point += satisfy_list[now_num - 1]
  if (now_num - prev_num) == 1:
    sum_point += plus_satisfy_list[prev_num - 1]
  prev_num = now_num
  
print(sum_point)

Submission status: Wrong Answer

Solution code:
N = int(input())
Ai = [int(i) for i in input().split(" ")]
Bi = [int(i) for i in input().split(" ")]
Ci = [int(i) for i in input().split(" ")]

res = 0
pre_i = None
for i in Ai:
  res += Bi[i-1]
  if i+1 == pre_i:
    res += Ci[i-1]
  pre_i = i

  print(res)

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=[0]+list(map(int, input().split()))
print(sum(b)+sum(c)-c[a[0]-1])

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()]
sat = 0

for i in a:
  sat += b[i-1]
  pre = i
  if pre + 1 == i:
    sat += c[pre-1]

print(sat)

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a = [int(a) for a in input().split()]
b = [int(a) for a in input().split()]
c = [int(a) for a in input().split()]
ans=0
l=0
for i in range (n):
  ans += b[a[i]-1]
  if a[i] == l+1:
    ans += c[a[i]-2]
  l=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()))
c.append(0)
max=0

for i in range(N):
    max=max+b[i]+c[i-1]
print(max)

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.insert(0,0)
max=0

for i in range(N):
    max=max+b[i]+c[i]
print(max)

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

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

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

print(ans)

Submission status: Wrong Answer

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

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

tmp = 0
for b in A:
    total += B[b - 1]
    if (b - tmp == 1):
        total += C[tmp - 1]
    tmp = b

print(total)

Submission status: Wrong Answer

Solution code:
'''
 Author: fuad Ashraful Mehmet
 University of Asia Pacific
 created :09 Sep 2019 7.33 PM
 Category :   from At Coder

 Problem:https:  
'''

 
 

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]



#fuck python if you can its just owsam

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys

input = sys.stdin.readline
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] - a[i - 1]) == 1:
        ans += c[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()))

man = sum(B)

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

print(man)

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,b,c)
s = 0
b_ia = 0
for ia in a:
  #print(ia)
  s += b[ia-1]
  if (b_ia + 1) == ia:
    s+= c[b_ia-1]
  b_ia = ia
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()))
M=0
for i in range(N):
    A[i]-=1
for i in range(N-1):
    if A[i]+1==A[i+1]:
        M+=B[A[i]]+C[A[i]]
        print(M)
    else:
        M+=B[A[i]]
        print(M)
print(M+B[A[N-1]])

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N = int(input())
A = [int(v) - 1 for v in input().split()]
B = [int(v) for v in input().split()]
C = [int(v) for v in input().split()]

ans = 0
for v in A:
    ans += B[v]

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

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

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

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

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

Submission status: Wrong Answer

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

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

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

for i in range(1,n+1):
    A = a[i-1]
    ans += b[A-1]
    if i == 1:
        pass
    elif ex_A == n:
        pass
    else:
        ans += c[ex_A-1]
    
    ex_A = A

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

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

Submission status: Wrong Answer

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

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

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
bonus = n
for a in A:
	a -= 1
	print(bonus,a)
	ans += B[a]
	if a-1 == bonus:
		ans += C[a-1]
	bonus = a
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()))
C.append(0)
lastly_eaten = A[n-1]
C[lastly_eaten-1]=0
print(sum(C)+sum(B))

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

satify = 0
first = a[0]
last = a[-1]


for i in range(1,len(a)+1):
    if i == first or i == last or i == n:
        satify += b[i-1]
    else:
        satify += b[i-1] + c[i-1]
        
print(satify)

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

satify = 0

for i in range(len(a)):
    if i == 0 or a[i-1] == n:
        satify += b[a[i]-1]
    else:
        satify += b[a[i]-1] + c[a[i-1]-1]
        
print(satify)

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

satify = 0
n_flg = True

for i in range(len(a)):
    if not n_flg:
      satify += b[a[i]-1] + c[a[i-1]-1]
      if a[i] == n:
        n_flg = True
    else:
      satify += b[a[i]-1]
      n_flg = False
      if a[i] == n:
        n_flg = True
        
print(satify)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = [int(s) for s in input().split()]
b_list = [int(s) for s in input().split()]
c_list = [int(s) for s in input().split()]

manzokudo = 0
prev_a = 0

for jun in a_list:
    manzokudo = manzokudo + b_list[jun-1]
    if jun > 1:
        if jun == prev_a + 1:
            manzokudo = manzokudo + c_list[prev_a-1]
    prev_a = jun
    print(prev_a)
        
print(manzokudo)

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

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

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

print(res)

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

print(ans)

Submission status: Wrong Answer

Solution code:
nums = list(map(int, input().split()))
orders = list(map(int, input().split()))
su1 = list(map(int, input().split()))
su2 = list(map(int, input().split()))

total = 0
lastmeal = 0
for i, num in enumerate(orders):
    if i==0:
        total += su1[num-1]
    else:
        if lastmeal != len(su2)+1:
            total += su1[num-1] + su2[lastmeal-1]
        else:
            total += su1[num-1]
    lastmeal = num
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()))
  
bj=0
newlist=0
for j in A:
  newlist += B[j-1]
  if j-bj==1: 
    newlist += C[j-2]
  bj=j

print(newlist)

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

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

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+=c[i]
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()))
 
manzoku = 0
prev = 0
 
for a in A:
  manzoku += B[a-1]
  if prev == a and prev != N:
    manzoku += C[prev-1]
  prev = a
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()))
 
manzoku = 0
prev = 0
 
for a in A:
  manzoku += B[a-1]
  if prev == a and prev != 0:
    manzoku += C[prev-1]
  prev = a
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()))
 
manzoku = 0
prev = 0
 
for a in A:
  manzoku += B[a-1]
  if prev == a:
    manzoku += C[prev-1]
  prev = a
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()))

answer = 0

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().rstrip().split()]
B = [int(i) for i in input().rstrip().split()]
if N >=2:
    C = [int(i) for i in input().rstrip().split()]

point = 0
node = -1
for i in range(N):
    point += B[A[i]-1]
    if A[i] - node == 1:
        point += C[i-2]
    node = A[i]

print(point)

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(' ')))
              
# print(N)#
# print(A_LIST)
# print(B_LIST)
# print(C_LIST)

ans = 0 
prev_a = 0
for a in A_LIST:
  # print("A {}".format(a))
  # print("prev_a {}".format(prev_a))
  ans += B_LIST[a-1]
  if prev_a + 1  == a:
    # print("a:{}".format(str(a)))
    ans += C_LIST[a - 2]
  
  prev_a = a
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()))
mem = set()
s=0
last =-5
for v in a:
    s+=b[v-1]
    if last+1 ==v and last+1<n:
        s+=c[last-1]
    last=v
print(s)

Submission status: Wrong Answer

Solution code:
N=int(input())
Alist=list(map(int,input().split()))
Blist=list(map(int,input().split()))
Clist=list(map(int,input().split()))

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



print(sum(Blist)+Cplus)

Submission status: Wrong Answer

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

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()))
n=int(0)
manzoku=int(0)
hantei = int(1)
if A[0] == hantei:
        manzoku += sum(C) + sum(B)
else:
        manzoku += sum(C) - C[A[0]-2] +sum(B)

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

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

print(ans)

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
prev = 0
 
for a in A:
  manzoku += B[a-1]
  if prev != 0 and prev != N and prev == a:
    manzoku += C[prev-1]
  prev = a
print(manzoku)

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 range(len(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()))
 
manzoku = 0
prev = 0
 
for a in A:
  manzoku += B[a-1]
  if prev != 0 and prev != N:
    manzoku += C[prev-1]
  prev = a
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()))

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

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n = int(input())
a = [ int(x) for x in stdin.readline().rstrip().split()]
b = [ int(x) for x in stdin.readline().rstrip().split()]
c = [ int(x) for x in stdin.readline().rstrip().split()]
cnt = 0

for i in range(n):
    j = a[i]-1
    cnt += b[j]
    if i>0:
        if a[i]-1 == a[i-1]:
            if len(c) > j:
                cnt+=c[a[i-1]-1]

print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = input().split()
y = input().split()
z = input().split()
x_i = [int(s_x) for s_x in x]
y_i = [int(s_y) for s_y in y]
z_i = [int(s_z) for s_z in z]
m = 0
i_bef = 0
for i in x_i:
    if i_bef == n or i ==x_i[0]:
        m = m + y_i[i-1]
    else:
        m = m + y_i[i-1] + z_i[i_bef-1]
    i_bef = i
print(m)

Submission status: Wrong Answer

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

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

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

ans += b[a[n-1]-1]

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[int(_) for _ in input().split()]
B=[int(_) for _ in input().split()]
C=[int(_) for _ in input().split()]
ans=0
a=0
for i in A:
  ans+=B[i-1]
  if i==a+1:
    ans+=C[a-1]
  a=i  
print(ans)

Submission status: Wrong Answer

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

result = 0
j = 0
for i in a:
  m = int(i) - 1
  result += int(b[m])
  if (not (m == 0)) and (j + 1 == m):
      result += int(c[j])
  j = m
print(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()))
c.sort()
if len(c)>1:
  c.pop()
x = sum(b)+sum(c)
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()))
n=int(0)
manzoku=int(0)
hantei = int(1)
if A[0] == hantei:
        manzoku += sum(C) + sum(B)

else:
        manzoku += sum(C) - C[A[0]-2] +sum(B)

print(manzoku)