結果
問題 | No.3072 Speedrun Query |
ユーザー |
![]() |
提出日時 | 2025-03-14 23:07:48 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,547 bytes |
コンパイル時間 | 390 ms |
コンパイル使用メモリ | 82,280 KB |
実行使用メモリ | 158,492 KB |
最終ジャッジ日時 | 2025-03-14 23:08:02 |
合計ジャッジ時間 | 12,435 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 3 WA * 18 |
ソースコード
import sysinput = sys.stdin.readlinen, ka, kb = map(int, input().split())a = list(map(int, input().split()))b = list(map(int, input().split()))sa = nfor v in b:ok, ng = 0, kawhile ng - ok != 1:vs = (ok + ng) >> 1if a[vs] < v:ok = vselse:ng = vssa = min(sa, abs(a[ok] - v))if ng != ka:sa = min(sa, abs(a[ng] - v))Q = int(input())for _ in range(Q):s, t = map(int, input().split())ok, ng = 0, kawhile ng - ok != 1:vs = (ok + ng) >> 1if a[vs] < s:ok = vselse:ng = vscas = abs(a[ok] - s)if ng != ka:cas = min(cas, abs(a[ng] - s))ok, ng = 0, kawhile ng - ok != 1:vs = (ok + ng) >> 1if a[vs] < t:ok = vselse:ng = vscat = abs(a[ok] - t)if ng != ka:cat = min(cat, abs(a[ng] - t))ok, ng = 0, kbwhile ng - ok != 1:vs = (ok + ng) >> 1if b[vs] < s:ok = vselse:ng = vscbs = abs(b[ok] - s)if ng != kb:cbs = min(cbs, abs(b[ng] - s))ok, ng = 0, kbwhile ng - ok != 1:vs = (ok + ng) >> 1if b[vs] < t:ok = vselse:ng = vscbt = abs(b[ok] - t)if ng != kb:cbt = min(cbt, abs(b[ng] - t))ans = 10**9ans = min(ans, cas + cat)ans = min(ans, cbs + cbt)ans = min(ans, cas + cbt + sa)ans = min(ans, cbs + cat + sa)print(ans)