結果
問題 | No.1597 Matrix Sort |
ユーザー | shotoyoo |
提出日時 | 2021-07-10 01:06:32 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,077 bytes |
コンパイル時間 | 402 ms |
コンパイル使用メモリ | 87,024 KB |
実行使用メモリ | 277,052 KB |
最終ジャッジ日時 | 2023-09-14 12:32:47 |
合計ジャッジ時間 | 4,505 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 72 ms
71,472 KB |
testcase_01 | AC | 79 ms
75,308 KB |
testcase_02 | AC | 77 ms
75,340 KB |
testcase_03 | AC | 150 ms
100,504 KB |
testcase_04 | TLE | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
ソースコード
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 dl = {} dr = {} def bl(v): if v in dl: return dl[v] else: dl[v] = _bl(b, v) return dl[v] def br(v): if v in dr: return dr[v] else: dr[v] = _br(b,v) return dr[v] def sub(x): val = 0 for i in range(n): v = a[i] ind = bl(p-v) i0 = br(x-v) i1 = br(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)