結果

問題 No.1597 Matrix Sort
ユーザー shotoyooshotoyoo
提出日時 2021-07-09 23:19:24
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 859 bytes
コンパイル時間 1,260 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 104,036 KB
最終ジャッジ日時 2023-09-14 10:49:30
合計ジャッジ時間 35,586 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
70,944 KB
testcase_01 AC 79 ms
74,724 KB
testcase_02 AC 79 ms
75,152 KB
testcase_03 AC 151 ms
100,428 KB
testcase_04 TLE -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 TLE -
testcase_09 TLE -
testcase_10 AC 712 ms
101,648 KB
testcase_11 AC 1,164 ms
101,464 KB
testcase_12 AC 1,142 ms
104,036 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 AC 987 ms
104,032 KB
testcase_16 AC 1,421 ms
102,144 KB
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 AC 245 ms
102,728 KB
testcase_25 AC 188 ms
102,368 KB
testcase_26 AC 72 ms
71,272 KB
testcase_27 AC 72 ms
71,196 KB
testcase_28 AC 73 ms
71,284 KB
testcase_29 AC 82 ms
75,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


n,k,p = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort()
from bisect import bisect_left as bl, bisect_right as br
def sub(x):
    val = 0
    for i in range(n):
        v = a[i]
        ind = bl(b, p-v)
        i0 = br(b, x-v)
        i1 = br(b, x+p-v)
#         print(v, ind, i0, i1, x)
        if i0>0:
            val += min(i0, ind)
        if i1>=ind:
            val += (i1-ind)
        if val>=k:
            return 0
    return 1
l = -1
r = p+1
while abs(l-r)>1:
    m = (l+r)//2
    if sub(m):
        l = m
    else:
        r = m
ans = r
print(ans)
0