結果
問題 |
No.3072 Speedrun Query
|
ユーザー |
![]() |
提出日時 | 2025-03-21 22:28:16 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 697 bytes |
コンパイル時間 | 293 ms |
コンパイル使用メモリ | 82,500 KB |
実行使用メモリ | 158,796 KB |
最終ジャッジ日時 | 2025-03-21 22:28:39 |
合計ジャッジ時間 | 7,260 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 6 TLE * 4 -- * 11 |
ソースコード
import sys import bisect input = sys.stdin.readline N,Ka,Kb=map(int,input().split()) A=list(map(int,input().split())) B=list(map(int,input().split())) Q=int(input()) inf=10**20 a2b=inf for a in A: bi=bisect.bisect_left(B,a) if bi<len(B): a2b=min(a2b,B[bi]-a) if 0<=bi-1<len(B): a2b=min(a2b,a-B[bi-1]) def dist(A,a): bi=bisect.bisect_left(A,a) res=inf if bi<len(A): res = min(res,A[bi]-a) if 0<=bi-1<len(A): res = min(res,a-A[bi-1]) return res for _ in range(Q): s,t=map(int,input().split()) s2a=dist(A,s) s2b=dist(B,s) t2a=dist(A,t) t2b=dist(B,t) print(min(abs(t-s),s2a+t2a,s2b+t2b,s2a+a2b+t2b,s2b+a2b+t2a))