結果

問題 No.1597 Matrix Sort
ユーザー shotoyooshotoyoo
提出日時 2021-07-09 22:06:36
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 866 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,044 KB
実行使用メモリ 104,464 KB
最終ジャッジ日時 2023-09-14 09:13:08
合計ジャッジ時間 35,407 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,184 KB
testcase_01 AC 72 ms
75,412 KB
testcase_02 AC 74 ms
75,352 KB
testcase_03 TLE -
testcase_04 TLE -
testcase_05 TLE -
testcase_06 AC 1,499 ms
101,416 KB
testcase_07 AC 1,465 ms
101,456 KB
testcase_08 TLE -
testcase_09 TLE -
testcase_10 AC 1,062 ms
101,940 KB
testcase_11 AC 1,034 ms
101,736 KB
testcase_12 AC 1,118 ms
104,152 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 AC 928 ms
104,464 KB
testcase_16 AC 1,296 ms
102,444 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 229 ms
103,028 KB
testcase_25 AC 203 ms
102,636 KB
testcase_26 AC 67 ms
71,296 KB
testcase_27 AC 68 ms
71,340 KB
testcase_28 AC 67 ms
71,492 KB
testcase_29 AC 74 ms
75,560 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 val
l = -1
r = p+1
while abs(l-r)>1:
    m = (l+r)//2
    if sub(m)<k:
        l = m
    else:
        r = m
ans = r
print(ans)
0