結果

問題 No.2370 He ate many cakes
ユーザー rin204
提出日時 2023-11-23 22:49:37
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 219 ms / 2,000 ms
コード長 511 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 247 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 164,608 KB
最終ジャッジ日時 2026-04-13 11:32:38
合計ジャッジ時間 3,515 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from bisect import bisect_left

n, k = map(int, input().split())
A = list(map(int, input().split()))
L = A[: n // 3]
R = A[n // 3 :]


def f(A):
    res = [0]
    for a in A:
        le = len(res)
        for i in range(le):
            res.append(res[i] + a)
    res.sort()
    return res


L = f(L)
R = f(R)
l = -1 << 60
r = 1 << 60
while r - l > 1:
    m = (l + r) // 2
    cnt = 0
    for a in L:
        cnt += len(R) - bisect_left(R, m - a)
    if cnt < k:
        r = m
    else:
        l = m

print(l)
0