結果

問題 No.1597 Matrix Sort
ユーザー PNJPNJ
提出日時 2023-11-24 07:49:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 334 ms / 1,500 ms
コード長 522 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 181,136 KB
最終ジャッジ日時 2023-11-24 07:49:42
合計ジャッジ時間 7,412 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,460 KB
testcase_01 AC 44 ms
53,460 KB
testcase_02 AC 39 ms
53,460 KB
testcase_03 AC 278 ms
166,316 KB
testcase_04 AC 328 ms
166,440 KB
testcase_05 AC 299 ms
166,444 KB
testcase_06 AC 285 ms
166,428 KB
testcase_07 AC 334 ms
166,300 KB
testcase_08 AC 257 ms
166,480 KB
testcase_09 AC 294 ms
166,480 KB
testcase_10 AC 187 ms
180,836 KB
testcase_11 AC 184 ms
166,480 KB
testcase_12 AC 109 ms
102,144 KB
testcase_13 AC 155 ms
111,160 KB
testcase_14 AC 308 ms
166,544 KB
testcase_15 AC 111 ms
102,412 KB
testcase_16 AC 142 ms
111,040 KB
testcase_17 AC 237 ms
166,652 KB
testcase_18 AC 276 ms
166,432 KB
testcase_19 AC 232 ms
166,424 KB
testcase_20 AC 214 ms
166,484 KB
testcase_21 AC 212 ms
166,504 KB
testcase_22 AC 217 ms
165,420 KB
testcase_23 AC 193 ms
181,136 KB
testcase_24 AC 80 ms
98,060 KB
testcase_25 AC 77 ms
97,676 KB
testcase_26 AC 38 ms
53,460 KB
testcase_27 AC 38 ms
53,460 KB
testcase_28 AC 38 ms
53,460 KB
testcase_29 AC 119 ms
137,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda: sys.stdin.readline().strip()
import bisect
N,K,P = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

R = [0 for i in range(P)]
for a in A:
  R[a] += 1
for i in range(P-1):
  R[i+1] += R[i]

l = -1
r = P - 1
while r - l > 1:
  m = (l + r) // 2
  res = 0
  for b in B:
    # a + b は 0 ~ 2*P - 1. m,m+P
    if m - b >= 0:
      res += R[m-b]
    x = min(P + m - b,P - 1)
    res += (R[x] - R[P-1-b])
  if res < K:
    l = m
  else:
    r = m
print(r)
0