結果

問題 No.1597 Matrix Sort
ユーザー shotoyooshotoyoo
提出日時 2021-07-10 00:39:53
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 859 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 86,636 KB
実行使用メモリ 104,304 KB
最終ジャッジ日時 2023-09-14 12:00:45
合計ジャッジ時間 34,896 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,120 KB
testcase_01 AC 76 ms
75,096 KB
testcase_02 AC 77 ms
75,100 KB
testcase_03 AC 154 ms
100,420 KB
testcase_04 TLE -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 TLE -
testcase_09 TLE -
testcase_10 AC 686 ms
101,588 KB
testcase_11 AC 1,086 ms
101,436 KB
testcase_12 AC 1,120 ms
103,940 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 AC 969 ms
104,304 KB
testcase_16 AC 1,374 ms
102,312 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 237 ms
102,628 KB
testcase_25 AC 181 ms
102,052 KB
testcase_26 AC 72 ms
71,140 KB
testcase_27 AC 71 ms
71,368 KB
testcase_28 AC 72 ms
70,916 KB
testcase_29 AC 81 ms
75,304 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