結果
問題 |
No.1597 Matrix Sort
|
ユーザー |
![]() |
提出日時 | 2021-08-09 22:11:43 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 821 bytes |
コンパイル時間 | 286 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 59,776 KB |
最終ジャッジ日時 | 2024-09-21 21:23:57 |
合計ジャッジ時間 | 3,996 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 3 TLE * 1 -- * 23 |
ソースコード
import bisect N,K,P = map(int,input().split()) A = list(map(int,input().split())) B = list(map(int,input().split())) A.sort() B.sort() dic = {} dic[-1] = 0 suma = 1 def check_o(n): x = bisect.bisect_left(A, n) y = bisect.bisect_right(A, n) if x != y: return x else: return x - 1 A2 = [] for a in A: dic[a] = suma dic[P + a] = N + suma suma += 1 A2.append(P + a) A = [-1] + A + A2 #print(A) #print(dic) def check(T): num = 0 for b in B: x = check_o(P+T-b) y = check_o(P-b-1) num += dic[A[x]] - dic[A[y]] #print(b,P+T-b,A[x],P-b-1,A[y]) #print(T,num) return (num < K) lb = 0 ub = P while ub - lb > 1: mid = (ub + lb) // 2 if check(mid): lb = mid else: ub = mid print(lb+1)