結果

問題 No.1457 ツブ消ししとるなHard
ユーザー nasubi24nasubi24
提出日時 2021-03-31 21:34:34
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 605 bytes
コンパイル時間 335 ms
コンパイル使用メモリ 86,952 KB
実行使用メモリ 76,564 KB
最終ジャッジ日時 2023-08-21 23:48:43
合計ジャッジ時間 3,068 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
76,092 KB
testcase_01 AC 70 ms
71,464 KB
testcase_02 AC 75 ms
75,912 KB
testcase_03 AC 72 ms
71,652 KB
testcase_04 AC 103 ms
76,516 KB
testcase_05 AC 102 ms
76,164 KB
testcase_06 AC 106 ms
76,544 KB
testcase_07 AC 71 ms
71,516 KB
testcase_08 AC 74 ms
76,088 KB
testcase_09 AC 77 ms
76,128 KB
testcase_10 AC 76 ms
76,128 KB
testcase_11 AC 73 ms
75,956 KB
testcase_12 AC 91 ms
76,564 KB
testcase_13 AC 80 ms
75,984 KB
testcase_14 AC 79 ms
76,216 KB
testcase_15 AC 80 ms
76,512 KB
testcase_16 AC 73 ms
76,108 KB
testcase_17 AC 77 ms
76,020 KB
testcase_18 AC 73 ms
75,704 KB
testcase_19 AC 103 ms
76,464 KB
testcase_20 AC 70 ms
75,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m,x,y,z=map(int,input().split())
a=list(map(int,input().split()))
cnt1=0
cnt2=0
b=[]
for i in range(n):
    if a[i]>=x:
        cnt1+=a[i]
        cnt2+=1
    elif a[i]>y:
        b.append(a[i])
dp=[[0]*(5000) for _ in range(len(b)+1)]
dp[0][0]=1
for i in range(len(b)):
    c=b[i]
    for j in range(i,-1,-1):
        for k in range(5000):
            if dp[j][k]!=0:
                dp[j+1][k+c]+=dp[j][k]
if cnt2>m:
    print("Handicapped")
else:
    ans=0
    for i in range(min(len(b)+1,m-cnt2+1)):
        if z*(cnt2+i)-cnt1>=0 and cnt2+i>0:
            ans+=dp[i][z*(cnt2+i)-cnt1]
    print(ans)
0