結果
問題 |
No.1460 Max of Min
|
ユーザー |
|
提出日時 | 2021-03-29 14:35:11 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,044 bytes |
コンパイル時間 | 88 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 22,016 KB |
最終ジャッジ日時 | 2024-11-29 10:04:40 |
合計ジャッジ時間 | 43,609 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 77 TLE * 14 |
ソースコード
import heapq INF=10**18+1 def check(X): b=[] for i in range(K-1,-1,-1): if B[i]>=X: b+=[K-i] if len(b)==0: return N<K and A[N]>=X M=b[0] dist=[INF for i in range(K+M)] Q=[] for i in range(K): if A[i]>=X: dist[i]=i heapq.heappush(Q,(i,i)) while Q: c,v=heapq.heappop(Q) if dist[v]<c: continue for j in b: if v<K: if v+j>=K and dist[K+(v+j)%M]>c+j: dist[K+(v+j)%M]=c+j heapq.heappush(Q,(c+j,K+(v+j)%M)) else: if dist[K+(v-K+j)%M]>c+j: dist[K+(v-K+j)%M]=c+j heapq.heappush(Q,(c+j,K+(v-K+j)%M)) if N<K: return dist[N]<=N else: return dist[K+N%M]<=N K,N=map(int,input().split()) A=list(map(int,input().split())) B=list(map(int,input().split())) ok=-INF ng=INF while ng-ok>1: mid=(ok+ng)//2 if check(mid): ok=mid else: ng=mid print(ok)