結果

問題 No.1597 Matrix Sort
ユーザー googol_S0
提出日時 2021-07-09 23:13:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 384 ms / 1,500 ms
コード長 457 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 103,936 KB
最終ジャッジ日時 2024-07-01 18:15:50
合計ジャッジ時間 8,306 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *
N,K,P=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
B=list(map(int,input().split()))
B.sort()
L,R=0,P
while L<R:
  M=(L+R)>>1
  C=0
  x,y,z=0,0,0
  for i in range(N):
    while x<N and B[x]<=M-A[i]:
      x+=1
    while y<N and B[y]<=P+M-A[i]:
      y+=1
    while z<N and B[z]<P-A[i]:
      z+=1
    if M>=A[i]:
      C+=x+y-z
    else:
      C+=y-z
  if C>=K:
    R=M
  else:
    L=max(L+1,M)
print(L)
0