結果

問題 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
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

import sys
input = sys.stdin.readline
n, ka, kb = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sa = n
for v in b:
ok, ng = 0, ka
while ng - ok != 1:
vs = (ok + ng) >> 1
if a[vs] < v:
ok = vs
else:
ng = vs
sa = 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, ka
while ng - ok != 1:
vs = (ok + ng) >> 1
if a[vs] < s:
ok = vs
else:
ng = vs
cas = abs(a[ok] - s)
if ng != ka:
cas = min(cas, abs(a[ng] - s))
ok, ng = 0, ka
while ng - ok != 1:
vs = (ok + ng) >> 1
if a[vs] < t:
ok = vs
else:
ng = vs
cat = abs(a[ok] - t)
if ng != ka:
cat = min(cat, abs(a[ng] - t))
ok, ng = 0, kb
while ng - ok != 1:
vs = (ok + ng) >> 1
if b[vs] < s:
ok = vs
else:
ng = vs
cbs = abs(b[ok] - s)
if ng != kb:
cbs = min(cbs, abs(b[ng] - s))
ok, ng = 0, kb
while ng - ok != 1:
vs = (ok + ng) >> 1
if b[vs] < t:
ok = vs
else:
ng = vs
cbt = abs(b[ok] - t)
if ng != kb:
cbt = min(cbt, abs(b[ng] - t))
ans = 10**9
ans = min(ans, cas + cat)
ans = min(ans, cbs + cbt)
ans = min(ans, cas + cbt + sa)
ans = min(ans, cbs + cat + sa)
print(ans)
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0