結果

問題 No.2759 Take Pictures, Elements?
ユーザー D M
提出日時 2025-02-19 15:55:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 256 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 82,748 KB
実行使用メモリ 62,204 KB
最終ジャッジ日時 2025-06-20 13:22:09
合計ジャッジ時間 2,015 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
n,q=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
D=defaultdict(int)
for i,j in enumerate(A):
    D[j]=i
now=0
ans=0
for i in B:
    ans+=abs(now-D[i])
    now=D[i]
print(ans)
0