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 = input()
line1 = input()
line2 = input()
line3 = input()

a_list = line1.split(" ")
a_list = [int(a) for a in a_list]
b_list = line2.split(" ")
b_list = [int(b) for b in b_list]
c_list = line3.split(" ")
c_list = [int(c) for c in c_list]

temp = a_list[0]
ans = 0
for a in a_list:
    if a == temp + 1:
        ans = ans + b_list[a-1] + c_list[temp-1]
        print(ans)
    else:
        ans = ans + b_list[a-1]
        print(ans)
    temp = a
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a_l = list(map(int, input().split()))
    b_l = list(map(int, input().split()))
    c_l = list(map(int, input().split()))
    res = 0
    pre = 1
    for a in a_l:
        res += b_l[a-1]
        if a - pre == 1:
            res += c_l[pre-1]
        pre = a
    print(res)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
num = int(input())
index = list(map(int, input().split()))
point = list(map(int, input().split()))
add = list(map(int, input().split()))

total = 0
for i in range(num):
  total += point[index[i]-1]

for j in range(num-1):
  if index[j+1] == index[j]+ 1:
    total += add[j]

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

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(lambda x: int(x) - 1, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
prev = -1
for i in range(N):
    ans += B[A[i]]
    if A[i] - prev == 1:
        ans += C[prev]
    prev = 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()))
cnt = 0
for i in range(N):
    if (cnt!= 0) and (a[i]==a[i-1]+1):
        cnt += c[i-2]

    cnt += b[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()))

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

Submission status: Wrong Answer

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

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

ans=sum(b)

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

ans = 0

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

print(a,b,c)

ans = 0

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

m=0
# 0で初期化すると最初が1の時にだめ
at=0
for i,ai in enumerate(a):
    m+=b[ai-1]
    if ai == at+1:
        m+=c[at-1]
    at=ai
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()))
D = []
for i in range(N-1):
  if A[i+1] - A[i] == 1:
    D.append(C[i-1])
for j in range(N):
  D.append(B[j])
print(sum(D))

Submission status: Wrong Answer

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


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

ans = sum(b)
for i in range(n-1):
    print(ans)
    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 = [0]*n

t = list(map(int, input().split()))
for i in range(n-1):
  c[i] = t[i]
  

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

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

Submission status: Wrong Answer

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

s=sum(b)

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

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

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

for j in range(0, N-1):
    if A[j+1] - A[j] == 1 and j != 0:
        score += C[j-1]
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()))
sum = 0

for i in range(len(a)):
    sum += b[a[i] - 1]
    print("i:{0} sum{1}".format(i, sum))
    if(i != len(a) - 1 and a[i] + 1 == a[i + 1]):
        sum += c[a[i] - 1]
        #print("i:{0} sum{1}".format(i, sum))#

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(len(a)):
    sum += b[a[i] - 1]
    print("i:{0} sum{1}".format(i, sum))
    if(i != len(a) - 1 and a[i] + 1 == a[i + 1]):
        sum += c[a[i] - 1]
        print("i:{0} sum{1}".format(i, sum))

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

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
t = 99
for i in a:
  if t < n:
    s += c[t-1]
  s += b[i-1]
  t = 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()))
count=sum(B)
print(count)
for i in range(N-1):
    if A[i]+1==A[i+1]:
        count=count+C[A[i]-1]
print(count)

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

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

A.append(0)

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

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

for j in range(N):
  total = total + B[j]

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

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

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()]
#ここまで入力
manzoku = 0
for i in range(n):
    if a[i] ==n-1 or i == n-1:
        manzoku += b[a[i]]
    else:
        manzoku += (b[a[i]]+c[a[i]])
print(manzoku)

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()]
#ここまで入力
manzoku = 0
for i in range(n):
    if a[i] ==n-1:
        manzoku += b[a[i]]
    elif i == n-1:
        manzoku += b[a[i]]
    else:
        manzoku += (b[a[i]]+c[a[i]])
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()]
#ここまで入力
manzoku = 0
for i in range(n):
    if a[i] ==n:
        manzoku += b[a[i]-1]
    elif i == n-1:
        manzoku += b[a[i]-1]
    else:
        manzoku += (b[a[i]-1]+c[a[i]-1])
print(manzoku)

Submission status: Wrong Answer

Solution code:
import sys

[N] = [int(x) for x in sys.stdin.readline().split(" ")]

As = [int(x) - 1 for x in sys.stdin.readline().split(" ")]
Bs = [int(x) for x in sys.stdin.readline().split(" ")]
Cs = [int(x) for x in sys.stdin.readline().split(" ")]

prev = -999
result = 0
for i in range(N):
    a = As[i]
    print("a", a)
    result += Bs[a]
    print("b", Bs[a], result)
    if a == prev+1:
        result += Cs[prev]
        print("c", Cs[prev], result)
    prev = a

print(result)

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

m = a[-1]

print(sum(b) + c[m - 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()))
s=0
for i in range(N):
  if i>=2 and A[i]==A[i-1]+1:
    s=s+B[A[i]-1]+C[i-2]
  else:
    s=s+B[A[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()))
s=0
for i in range(N):
  if i>=1 and A[i]==A[i-1]+1:
    s=s+B[A[i]-1]+C[i-1]
  else:
    s=s+B[A[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()))
d=0
for i in range(N):
  d+=b[a[i]-1]
  e=i
  if i != 0:
    if a[i]==a[e]+1:
      d+=c[i]
    
    
print(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(" ")))

b_sum = sum(b)

# c_sum = 0
# for i in range(n-1):
#     ai = a[i]
#     if ai != n:
#         c_sum += c[ai-1]
c_sum = sum(c)
if a[-1] != n:
    c_sum -= c[a[-1] - 1]
print(b_sum + c_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(" ")))

b_sum = sum(b)

c_sum = 0
for i in range(n-1):
    ai = a[i]
    if ai != n:
        c_sum += c[ai-1]

print(b_sum + c_sum)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_input = input()
a = a_input.split(" ")
b_input = input()
b = b_input.split(" ")
c_input = input()
c = c_input.split(" ")

b_sum = 0
for i in range(n):
    b_sum += int(b[i])

c_sum = 0
for i in range(n-1):
    if int(a[i]) != n:
        c_sum += int(c[int(a[i])-1])
    else:
        c_sum += 0

sum = b_sum + c_sum
print(sum)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_input = input()
a = a_input.split(" ")
b_input = input()
b = b_input.split(" ")
c_input = input()
c = c_input.split(" ")

b_sum = 0
for i in range(n):
    b_sum += int(b[i])

c_sum = 0
for i in range(n-1):
    if int(a[i]) != n:
        c_sum += int(c[int(a[i])-1])
    else:
        continue

sum = b_sum + c_sum
print(sum)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_input = input()
a = a_input.split(" ")
b_input = input()
b = b_input.split(" ")
c_input = input()
c = c_input.split(" ")

b_sum = 0
for i in range(n):
    b_sum += int(b[i])

c_sum = 0
for i in range(n-1):
    if int(a[i]) != n:
        c_sum += int(c[int(a[i])-1])

sum = b_sum + c_sum
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())) + [0]

print(sum(b) + sum(c) - c[a[-1]-1])

Submission status: Wrong Answer

Solution code:
n = int(input())
alis = list(map(int, input().split()))
blis = list(map(int, input().split()))
clis = list(map(int, input().split()))
cache = 0
ans = 0
if n == 2 and alis[0] ==1:
    ans = sum([blis[0] + blis[1] + clis[0]])
else:
    for i in range(n):
        a = alis[i]
        b = blis[a - 1]
        ans += b
        if cache + 1 == a:
            ans += clis[a - 2]
        cache = a
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
alis = list(map(int, input().split()))
blis = list(map(int, input().split()))
clis = list(map(int, input().split()))
cache = 0
ans = 0
for i in range(n):
    a = alis[i]
    b = blis[a - 1]
    ans += b
    if cache + 1 == a:
        ans += clis[a - 2]
    cache = 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()))
sum=0
for i in range(len(A)-1):
  sum+=B[i]
  if A[i]+1==A[i+1]:
    sum+=C[i]
sum+=B[len(A)-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()))
m = 0
 
for i in range(n):
  m += b[a[i]-1]
  if i==0:
    continue
  if a[i] == a[i-1]+1:
    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):
  m += b[a[i]-1]
  if i==0:
    continue
  elif i==n-1:
    continue
  if a[i] == a[i-1]+1:
    m += c[i-1]
    
print(m)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(s) for s in input().split(' ')]
B = [int(s2) for s2 in input().split(' ')]
C = [int(s3) for s3 in input().split(' ')]

satis = 0

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

satis += sum(B)

print(satis)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(s) for s in input().split(' ')]
B = [int(s2) for s2 in input().split(' ')]
C = [int(s3) for s3 in input().split(' ')]

#satisfaction start value
satis = 0

#find two countinuously incremental numbers
for j in A[:]:
    for k in A[1:]:
        if j+1 == k:
            satis += C[j-1]

for i in A:
    satis += B[i-1]

print(satis)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(s) for s in input().split(' ')]
B = [int(s2) for s2 in input().split(' ')]
C = [int(s3) for s3 in input().split(' ')]

#satisfaction start value
satis = 0

#find two countinuously incremental numbers
for j in A[0:len(A)]:
    for k in A[1:len(A)]:
        if j+1 == k:
            satis += C[j-1]

for i in A:
    satis += B[i-1]

print(satis)

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

count = 0
for i in range(N):
	count += B[A[i]-1]
	# 最後は追加の満足度はないから省く
	if i != N-1:
		try:
			# 追加の満足度
			count += C[A[i]-1]
		except IndexError as e:
			pass

print(count)

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

for i in range(N):
    A[i] -= 1

#print(A)

for i in range(N):

    eat_num = A[i]

    #print(B[eat_num])

    ans += B[eat_num]

    try:
        if A[i] == A[i+1] - 1:
            #print("add C")
            print(C[A[i]])
            ans += C[A[i]]
    except:
        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()))
print(A[0])
ans=B[int(A[0])-1]

for i in range(1,n):
    if A[i-1]+1==A[i]:
        ans += B[int(A[i])-1]+C[int(A[i-1])-1]
    else:
        ans += B[int(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()))
res = b[a[0]-1]
for i in range(1, n):
    res += b[a[i]-1]
    if a[i-1] +1 == a[i]:
        res += c[i-2]
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()))
A.append(100)
B.append(100)
C.append(0)
ans=0
for i in range(1,N+1):
	ans+=B[A[i-1]-1]
	if A[i-1]==A[i]-1:
		ans+=C[i-2]
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input().strip())
A = [int(n)-1 for n in input().strip().split()]
B = list(map(int, input().strip().split()))
C = list(map(int, input().strip().split()))

c = 0
f = 1
for i in A:
    c += B[i]

    if i < N - 1 and not f == N:
        c += C[i]

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

result=0
count_c=0
buf=A[0]

for i in A:
    if(i-buf==1):
        result+=B[i-1]+C[count_c]
        count_c+=1
    else:
        result+=B[i-1]
    buf=i

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split()
a = [int(i) for i in a]
b = input().split()
b = [int(i) for i in b]
result= 0
for i in range(n):
  i = a[i]
for i in range (n):
  result += b[i]
c = input().split()
c = [int(i) for i in c]
for i in range (n):
  if a[i] - a[i-1] == 1:
    result += c[i-1]
  else:
    break
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())))
 
total = sum(B)
point = 0
for i in range(len(A) - 1):
    if A[i] + 1 == A[i+1]:
        point = point+C[i-1]
        print(point)
print(total+point)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))+[0]     ###料理
B = list(map(int, input().split()))     ###満足度
C = list(map(int, input().split()))  +[0]   ###連ちゃん

sum=sum(B)

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

print(sum)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))+[0]     ###料理
B = list(map(int, input().split()))     ###満足度
C = list(map(int, input().split()))     ###連ちゃん

sum=sum(B)

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

result=0
for i in range(N):
    result+=b[i]

for j in range(1,N):
    if a[j-1]+1==a[j]:
        print(a[j-1])
        result+=c[a[j-1]-1]

print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())
ai = list(map(int, input().split()))
bi = list(map(int, input().split()))
ci = list(map(int, input().split()))

#print(ai)
#print(bi)
#print(ci)

ans = 0
for i in range(n):
    t = ai[i]
    ans = ans+bi[t-1]
    if i >= 1 and ai[i-1] != n:
        ans = ans + ci[ai[i-1]-1]

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

As = [int(i) for i in input().split()]
Bs = [int(i) for i in input().split()]
Cs = [int(i) for i in input().split()]

# c_counter = 0
value = 0
previous_plate_index = -1

for i in range(N):    
    plate_index = As[i] - 1
    value += Bs[plate_index]
    if plate_index == previous_plate_index + 1:
            value += Cs[previous_plate_index]
    previous_plate_index = plate_index

print(value)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(lambda x: int(x), input().split()))
b = list(map(lambda x: int(x), input().split()))
c = list(map(lambda x: int(x), input().split()))
ans = 0
pre_a = 0
for i in a:
    ans += b[i-1]
    if i == pre_a + 1 :
        ans += c[pre_a-1]
    pre_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()))

ans = 0

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

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

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

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

bounas = 0

B_Sum = sum(B)

for x in A:
    if x == x+1:
        bounas += C[x-1]
        
print((bounas) + (B_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()))

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

a.append(23)

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

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

ans = 0
len_a = len(A)
for i in range(len_a):
    if (i == 0):
        ans += B[A[i]-1]
    else:
        if (A[i-1] != N):
            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()))
a=0
for co,i in enumerate(A):
    if co==0 :
        a+=B[i-1]
    if co>=1 :
        if A[co-1]!=N:
            a+=B[i-1]
            a+=C[A[co-1]-1]
        else:
            a+=B[i-1]
print(a)

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

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

Submission status: Wrong Answer

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

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



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