結果

問題 No.1597 Matrix Sort
ユーザー neterukunneterukun
提出日時 2021-07-09 22:23:05
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 690 bytes
コンパイル時間 1,166 ms
コンパイル使用メモリ 87,308 KB
実行使用メモリ 104,168 KB
最終ジャッジ日時 2023-09-14 09:38:13
合計ジャッジ時間 32,721 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,412 KB
testcase_01 AC 70 ms
71,412 KB
testcase_02 AC 71 ms
71,276 KB
testcase_03 TLE -
testcase_04 TLE -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 1,294 ms
103,776 KB
testcase_09 AC 1,342 ms
103,992 KB
testcase_10 AC 790 ms
102,920 KB
testcase_11 AC 646 ms
103,292 KB
testcase_12 AC 1,105 ms
103,372 KB
testcase_13 AC 1,490 ms
103,724 KB
testcase_14 TLE -
testcase_15 AC 762 ms
103,236 KB
testcase_16 AC 1,057 ms
103,772 KB
testcase_17 AC 1,197 ms
103,616 KB
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 AC 1,303 ms
103,840 KB
testcase_22 AC 1,208 ms
103,676 KB
testcase_23 AC 1,187 ms
103,524 KB
testcase_24 AC 194 ms
102,568 KB
testcase_25 AC 185 ms
102,308 KB
testcase_26 AC 72 ms
71,408 KB
testcase_27 AC 74 ms
71,380 KB
testcase_28 AC 71 ms
71,404 KB
testcase_29 AC 77 ms
75,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import bisect
input = sys.stdin.buffer.readline


def solve(val):
    cnt = 0
    for va in a:
        if va <= val:
            l = val - va
            r = p - va - 1
            cnt += bisect.bisect_right(b, l)
            cnt += n - bisect.bisect_right(b, r)
        else:
            l = p - va
            r = l + val + 1
            cnt += bisect.bisect_left(b, r) - bisect.bisect_left(b, l)
    return cnt

n, k, p = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

b = sorted(b)
ok = p
ng = -1
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if solve(mid) >= k:
        ok = mid
    else:
        ng = mid
print(ok)
0