結果

問題 No.1457 ツブ消ししとるなHard
ユーザー 👑 KazunKazun
提出日時 2021-06-14 03:18:30
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 851 bytes
コンパイル時間 684 ms
コンパイル使用メモリ 87,144 KB
実行使用メモリ 87,892 KB
最終ジャッジ日時 2023-08-25 12:02:06
合計ジャッジ時間 3,870 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
71,764 KB
testcase_01 AC 93 ms
71,628 KB
testcase_02 AC 90 ms
71,460 KB
testcase_03 AC 84 ms
71,688 KB
testcase_04 AC 100 ms
78,004 KB
testcase_05 AC 99 ms
77,884 KB
testcase_06 AC 162 ms
87,892 KB
testcase_07 AC 84 ms
71,764 KB
testcase_08 AC 90 ms
71,960 KB
testcase_09 AC 96 ms
77,596 KB
testcase_10 AC 100 ms
77,464 KB
testcase_11 AC 89 ms
71,908 KB
testcase_12 AC 115 ms
77,800 KB
testcase_13 AC 100 ms
77,724 KB
testcase_14 AC 99 ms
77,644 KB
testcase_15 AC 99 ms
77,632 KB
testcase_16 RE -
testcase_17 AC 84 ms
71,788 KB
testcase_18 AC 81 ms
71,708 KB
testcase_19 AC 110 ms
77,844 KB
testcase_20 AC 85 ms
71,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

N,M,X,Y,Z=map(int,input().split())
A=list(map(int,input().split()))

delete_like=delete_count=0
hold_like=hold_count=0

B=[]
for a in A:
    if a<=Y:
        delete_like+=a
        delete_count+=1
    elif a>=X:
        hold_like+=a
        hold_count+=1
    else:
        B.append(a-Z)

if hold_count>M:
    exit(print("Handicapped"))

if hold_count==N:
    exit(print(1 if sum(A)==N*Z else 0))

DP=[[defaultdict(int) for _ in range(len(B)+2)] for _ in range(len(B)+1)]
DP[0][0][0]=1

for i,b in enumerate(B,1):
    D=DP[i]; E=DP[i-1]
    for k in range(len(B)+1):
        e=E[k]
        d1=D[k]
        d2=D[k+1]
        for s in DP[i-1][k]:
            d1[s]+=e[s]
            d2[s+b]+=e[s]

U=hold_like-hold_count*Z
Ans=0
for i in range(M-hold_count+1):
    Ans+=DP[-1][i][-U]

if U==0:
    Ans-=1

print(Ans)
0