結果
問題 | No.1597 Matrix Sort |
ユーザー |
👑 ![]() |
提出日時 | 2021-07-09 23:48:49 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,438 ms / 1,500 ms |
コード長 | 806 bytes |
コンパイル時間 | 244 ms |
コンパイル使用メモリ | 82,324 KB |
実行使用メモリ | 102,656 KB |
最終ジャッジ日時 | 2024-07-01 18:45:09 |
合計ジャッジ時間 | 27,830 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
import bisectfrom sys import stdinimport sysN,K,P = map(int,stdin.readline().split())A = list(map(int,stdin.readline().split()))B = list(map(int,stdin.readline().split()))for i in range(N):A[i] %= PB[i] %= PA.sort()B.sort()#print (A,B,file=sys.stderr)l = -1r = P-1while r-l != 1:MID = (l+r)//2ans = 0for i in range(N):ZR = (P - A[i]) % PZIND = bisect.bisect_left(B,ZR)MR = (MID-A[i]) % PMIND = bisect.bisect_right(B,MR)if ZIND == MIND or (ZIND,MIND) in ( (0,N),(N,0) ):if (A[0]+B[0]) % P <= MID:ans += Nelse:ans += 0else:ans += (MIND-ZIND) % Nif ans >= K:r = MIDelse:l = MIDprint (r)