結果

問題 No.2329 Nafmo、イカサマをする
ユーザー navel_tosnavel_tos
提出日時 2023-05-29 20:45:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 139 ms / 2,000 ms
コード長 1,216 bytes
コンパイル時間 485 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 97,280 KB
最終ジャッジ日時 2024-06-08 19:26:14
合計ジャッジ時間 3,292 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,096 KB
testcase_01 AC 36 ms
52,480 KB
testcase_02 AC 37 ms
51,840 KB
testcase_03 AC 34 ms
52,352 KB
testcase_04 AC 35 ms
52,096 KB
testcase_05 AC 40 ms
51,840 KB
testcase_06 AC 38 ms
52,224 KB
testcase_07 AC 38 ms
51,840 KB
testcase_08 AC 58 ms
66,816 KB
testcase_09 AC 36 ms
52,480 KB
testcase_10 AC 34 ms
51,840 KB
testcase_11 AC 35 ms
52,864 KB
testcase_12 AC 37 ms
52,224 KB
testcase_13 AC 37 ms
52,480 KB
testcase_14 AC 35 ms
52,096 KB
testcase_15 AC 38 ms
52,352 KB
testcase_16 AC 35 ms
52,992 KB
testcase_17 AC 34 ms
52,224 KB
testcase_18 AC 37 ms
52,224 KB
testcase_19 AC 56 ms
66,560 KB
testcase_20 AC 45 ms
59,904 KB
testcase_21 AC 42 ms
58,880 KB
testcase_22 AC 46 ms
60,416 KB
testcase_23 AC 37 ms
52,224 KB
testcase_24 AC 35 ms
52,096 KB
testcase_25 AC 39 ms
58,496 KB
testcase_26 AC 35 ms
52,480 KB
testcase_27 AC 34 ms
52,224 KB
testcase_28 AC 34 ms
52,736 KB
testcase_29 AC 61 ms
70,528 KB
testcase_30 AC 37 ms
52,480 KB
testcase_31 AC 35 ms
52,736 KB
testcase_32 AC 34 ms
52,096 KB
testcase_33 AC 35 ms
52,352 KB
testcase_34 AC 36 ms
52,096 KB
testcase_35 AC 43 ms
60,160 KB
testcase_36 AC 72 ms
76,672 KB
testcase_37 AC 42 ms
59,392 KB
testcase_38 AC 36 ms
52,480 KB
testcase_39 AC 66 ms
70,272 KB
testcase_40 AC 63 ms
69,632 KB
testcase_41 AC 139 ms
97,280 KB
testcase_42 AC 63 ms
69,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#MMA Contest 015 H

'''
ここからAfterContest。

持ち点0。カードを上限K枚まで引く。バーストはM点超え。
引くならN枚から1枚を選び、得点に加算し、「カードを戻す」

Nは小さいしさ、愚直にシミュレーション、あ、だめですか。だめじゃないですね、やります。

2ケースTLE。たった2ケース・・・
くっそー 半分に分けるか
'''
from bisect import bisect_left as bL, bisect_right as bR
f=lambda:list(map(int,input().split()))
N,M,K=f(); A=f()+[0]; X=K//2; Y=K-X

candidate=set([0])
for k in range(X):
    score=set()
    for now in candidate:
        for next in A:
            if now+next<=M: score.add(now+next)
    candidate=score
    
candidate2=set([0])
for k in range(Y):
    score=set()
    for now in candidate2:
        for next in A:
            if now+next<=M: score.add(now+next)
    candidate2=score
candidate2=sorted(candidate2)

ans=0
for i in candidate:
    X=M-i; Z=bL(candidate2,X); Z2=Z-1
    if X==0: ans=i; continue
    if 0<=Z<len(candidate2) and i+candidate2[Z]<=M: ans=max(ans,i+candidate2[Z])
    if 0<=Z2<len(candidate2) and i+candidate2[Z2]<=M: ans=max(ans,i+candidate2[Z2])
print(ans)
0