結果

問題 No.2370 He ate many cakes
ユーザー titiatitia
提出日時 2023-07-04 05:20:49
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 697 bytes
コンパイル時間 672 ms
コンパイル使用メモリ 86,720 KB
実行使用メモリ 78,356 KB
最終ジャッジ日時 2023-09-25 02:49:23
合計ジャッジ時間 4,470 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,220 KB
testcase_01 AC 74 ms
71,324 KB
testcase_02 AC 71 ms
71,148 KB
testcase_03 AC 241 ms
78,072 KB
testcase_04 WA -
testcase_05 AC 74 ms
71,128 KB
testcase_06 AC 74 ms
71,244 KB
testcase_07 AC 73 ms
71,168 KB
testcase_08 AC 74 ms
71,288 KB
testcase_09 AC 74 ms
71,292 KB
testcase_10 AC 174 ms
77,316 KB
testcase_11 AC 243 ms
77,828 KB
testcase_12 AC 167 ms
77,436 KB
testcase_13 AC 230 ms
78,088 KB
testcase_14 AC 232 ms
78,356 KB
testcase_15 AC 242 ms
78,108 KB
testcase_16 AC 177 ms
77,408 KB
testcase_17 AC 252 ms
77,900 KB
testcase_18 AC 81 ms
75,972 KB
testcase_19 AC 84 ms
76,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from bisect import bisect_left

N,K=map(int,input().split())
A=list(map(int,input().split()))

if N==1:
    print(A[0])
    exit()

A.sort()

B=A[:N//2]
C=A[N//2:]

X=[0]

for b in B:
    Y=[]
    for x in X:
        Y.append(x+b)

    X=X+Y

X2=[0]
for b in C:
    Y=[]
    
    for x in X2:
        Y.append(x+b)

    X2=X2+Y

X.sort()
X2.sort()

OK=-40*10**9
NG=40*10**9

while OK<NG-1:
    mid=(OK+NG)//2

    count=0
    #count+=len(X2)-bisect_left(X2,mid)
    #count+=len(X)-bisect_left(X,mid)
    for x in X:
        count+=len(X2)-bisect_left(X2,mid-x)

    #print(mid,count)

    if count>=K:
        OK=mid
    else:
        NG=mid

print(OK)

    
0