結果
問題 | No.2329 Nafmo、イカサマをする |
ユーザー | navel_tos |
提出日時 | 2023-05-29 20:45:12 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 167 ms / 2,000 ms |
コード長 | 1,216 bytes |
コンパイル時間 | 378 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 97,024 KB |
最終ジャッジ日時 | 2024-12-28 10:17:44 |
合計ジャッジ時間 | 4,714 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
ソースコード
#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)