結果
| 問題 | No.2759 Take Pictures, Elements? |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-27 19:03:21 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 800 bytes |
| 記録 | |
| コンパイル時間 | 496 ms |
| コンパイル使用メモリ | 21,536 KB |
| 実行使用メモリ | 15,864 KB |
| 最終ジャッジ日時 | 2026-07-12 13:49:02 |
| 合計ジャッジ時間 | 9,338 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 2 -- * 19 |
ソースコード
x,y = map(int,input().split())
a_list=list(map(int,input().split()))
# {val: [idx,list]}
a_dict={}
for idx, a in enumerate(a_list):
if a in a_dict:
a_dict[a]=[*a_dict[a], idx]
else:
a_dict[a]=[idx]
b_list = list(map(int,input().split()))
pre_pos=0
# {pos: total_count}
count_dict={0:0}
for b in b_list:
pos_list=a_dict[b]
temp_count_dict={}
for p in pos_list:
for key in count_dict:
now_total=count_dict[key]
if p in temp_count_dict:
val=now_total+abs(p-key)
if val < temp_count_dict[p]:
temp_count_dict[p]=val
else:
temp_count_dict[p]=now_total+abs(p-key)
count_dict=temp_count_dict
print(min(count_dict.values()))