結果

問題 No.2329 Nafmo、イカサマをする
ユーザー navel_tosnavel_tos
提出日時 2023-05-29 20:45:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 163 ms / 2,000 ms
コード長 1,216 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 98,372 KB
最終ジャッジ日時 2023-08-27 23:54:26
合計ジャッジ時間 5,158 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,456 KB
testcase_01 AC 70 ms
71,288 KB
testcase_02 AC 70 ms
71,092 KB
testcase_03 AC 69 ms
71,288 KB
testcase_04 AC 74 ms
71,236 KB
testcase_05 AC 70 ms
71,368 KB
testcase_06 AC 70 ms
71,316 KB
testcase_07 AC 72 ms
71,328 KB
testcase_08 AC 87 ms
75,984 KB
testcase_09 AC 72 ms
71,244 KB
testcase_10 AC 69 ms
71,296 KB
testcase_11 AC 71 ms
71,056 KB
testcase_12 AC 68 ms
71,388 KB
testcase_13 AC 70 ms
71,248 KB
testcase_14 AC 71 ms
71,140 KB
testcase_15 AC 70 ms
71,464 KB
testcase_16 AC 70 ms
71,308 KB
testcase_17 AC 67 ms
71,484 KB
testcase_18 AC 70 ms
71,408 KB
testcase_19 AC 89 ms
76,212 KB
testcase_20 AC 76 ms
76,080 KB
testcase_21 AC 73 ms
75,860 KB
testcase_22 AC 80 ms
76,084 KB
testcase_23 AC 71 ms
71,140 KB
testcase_24 AC 70 ms
71,244 KB
testcase_25 AC 74 ms
75,796 KB
testcase_26 AC 69 ms
71,200 KB
testcase_27 AC 70 ms
71,244 KB
testcase_28 AC 71 ms
71,568 KB
testcase_29 AC 92 ms
76,308 KB
testcase_30 AC 70 ms
71,240 KB
testcase_31 AC 69 ms
71,204 KB
testcase_32 AC 69 ms
71,332 KB
testcase_33 AC 71 ms
71,548 KB
testcase_34 AC 70 ms
71,208 KB
testcase_35 AC 76 ms
76,136 KB
testcase_36 AC 101 ms
77,848 KB
testcase_37 AC 83 ms
75,984 KB
testcase_38 AC 69 ms
71,040 KB
testcase_39 AC 97 ms
78,172 KB
testcase_40 AC 94 ms
76,596 KB
testcase_41 AC 163 ms
98,372 KB
testcase_42 AC 92 ms
76,332 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