結果
| 問題 | No.2759 Take Pictures, Elements? |
| コンテスト | |
| ユーザー |
回転
|
| 提出日時 | 2025-11-14 14:56:36 |
| 言語 | PyPy3 (8.0.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 151 ms / 2,000 ms |
| + 725µs | |
| コード長 | 755 bytes |
| 記録 | |
| コンパイル時間 | 86 ms |
| コンパイル使用メモリ | 64,364 KB |
| 実行使用メモリ | 62,460 KB |
| 最終ジャッジ日時 | 2026-10-17 22:43:35 |
| 合計ジャッジ時間 | 3,619 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
import bisect
from collections import defaultdict
N,Q = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
place = defaultdict(list)
for i in range(N):
place[A[i]].append(i)
INF = 10**18
now = defaultdict(lambda:INF)
now[0] = 0
for i in range(Q):
next = defaultdict(lambda:INF)
for j in now:
left = bisect.bisect_right(place[B[i]],j) - 1
if(left != -1):
l = place[B[i]][left]
next[l] = min(next[l], now[j] + abs(j - l))
right = bisect.bisect_left(place[B[i]],j)
if(right != len(place[B[i]])):
r = place[B[i]][right]
next[r] = min(next[r], now[j] + abs(j - r))
now,next = next,now
print(min(now.values()))
回転