結果

問題 No.2370 He ate many cakes
ユーザー 👑 rin204rin204
提出日時 2023-11-23 22:49:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 278 ms / 2,000 ms
コード長 511 bytes
コンパイル時間 404 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 159,660 KB
最終ジャッジ日時 2023-11-23 22:49:51
合計ジャッジ時間 4,552 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 35 ms
53,460 KB
testcase_03 AC 278 ms
159,660 KB
testcase_04 AC 35 ms
53,460 KB
testcase_05 AC 34 ms
53,460 KB
testcase_06 AC 34 ms
53,460 KB
testcase_07 AC 34 ms
53,460 KB
testcase_08 AC 34 ms
53,460 KB
testcase_09 AC 34 ms
53,460 KB
testcase_10 AC 237 ms
159,608 KB
testcase_11 AC 262 ms
159,656 KB
testcase_12 AC 245 ms
159,612 KB
testcase_13 AC 246 ms
159,652 KB
testcase_14 AC 267 ms
159,652 KB
testcase_15 AC 248 ms
159,652 KB
testcase_16 AC 216 ms
159,616 KB
testcase_17 AC 264 ms
159,660 KB
testcase_18 AC 51 ms
64,072 KB
testcase_19 AC 44 ms
64,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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