結果

問題 No.1597 Matrix Sort
ユーザー ayaoniayaoni
提出日時 2021-07-09 21:57:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,157 ms / 1,500 ms
コード長 877 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 87,276 KB
実行使用メモリ 385,732 KB
最終ジャッジ日時 2023-09-14 08:55:13
合計ジャッジ時間 16,494 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,460 KB
testcase_01 AC 76 ms
71,584 KB
testcase_02 AC 77 ms
71,544 KB
testcase_03 AC 974 ms
384,556 KB
testcase_04 AC 1,157 ms
384,168 KB
testcase_05 AC 796 ms
384,200 KB
testcase_06 AC 794 ms
384,372 KB
testcase_07 AC 673 ms
384,248 KB
testcase_08 AC 671 ms
384,640 KB
testcase_09 AC 675 ms
384,740 KB
testcase_10 AC 601 ms
384,708 KB
testcase_11 AC 613 ms
384,628 KB
testcase_12 AC 142 ms
103,712 KB
testcase_13 AC 251 ms
171,236 KB
testcase_14 AC 715 ms
384,692 KB
testcase_15 AC 151 ms
103,880 KB
testcase_16 AC 210 ms
170,684 KB
testcase_17 AC 681 ms
384,624 KB
testcase_18 AC 715 ms
384,364 KB
testcase_19 AC 648 ms
384,468 KB
testcase_20 AC 641 ms
384,524 KB
testcase_21 AC 614 ms
384,364 KB
testcase_22 AC 619 ms
384,960 KB
testcase_23 AC 611 ms
385,732 KB
testcase_24 AC 165 ms
102,260 KB
testcase_25 AC 117 ms
101,720 KB
testcase_26 AC 79 ms
71,412 KB
testcase_27 AC 77 ms
71,284 KB
testcase_28 AC 78 ms
71,320 KB
testcase_29 AC 541 ms
368,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from itertools import accumulate
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N,K,P = MI()
A = LI()
B = LI()

count = [0]*P
for b in B:
    count[b] += 1
S_count = list(accumulate(count))

ng = -1
ok = P-1
while ng+1 < ok:
    mid = (ng+ok)//2
    c = 0
    for i in range(N):
        a = A[i]
        if mid >= a:
            c += S_count[mid-a]
        c += S_count[min(P-1,P+mid-a)]-S_count[P-a-1]
    if c >= K:
        ok = mid
    else:
        ng = mid

print(ok)
0