結果

問題 No.1597 Matrix Sort
コンテスト
ユーザー gr1msl3y
提出日時 2021-11-27 18:07:17
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 529 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 299 ms
コンパイル使用メモリ 85,168 KB
実行使用メモリ 516,776 KB
最終ジャッジ日時 2026-03-20 04:55:37
合計ジャッジ時間 11,427 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 MLE * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from itertools import accumulate
N, K, P = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ctA = [0]*P
ctB = [0]*P
for a, b in zip(A, B):
    ctA[a] += 1
    ctB[b] += 1

acumB = [0]+list(accumulate(ctB))


def solve(v):
    ct = 0
    for a in A:
        if v >= a:
            ct += acumB[v-a+1]
        ct += acumB[min(P, P+v-a+1)]-acumB[P-a]
    return ct >= K


l, r = -1, P-1
while r-l > 1:
    m = (l+r)//2
    if solve(m):
        r = m
    else:
        l = m

print(r)
0