結果

問題 No.1457 ツブ消ししとるなHard
ユーザー shotoyooshotoyoo
提出日時 2021-03-31 22:04:34
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 308 ms / 2,000 ms
コード長 839 bytes
コンパイル時間 634 ms
コンパイル使用メモリ 87,000 KB
実行使用メモリ 101,492 KB
最終ジャッジ日時 2023-08-22 02:00:29
合計ジャッジ時間 4,452 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,844 KB
testcase_01 AC 70 ms
71,232 KB
testcase_02 AC 92 ms
71,756 KB
testcase_03 AC 89 ms
71,536 KB
testcase_04 AC 102 ms
77,576 KB
testcase_05 AC 103 ms
77,844 KB
testcase_06 AC 308 ms
101,492 KB
testcase_07 AC 71 ms
71,552 KB
testcase_08 AC 72 ms
71,368 KB
testcase_09 AC 105 ms
77,576 KB
testcase_10 AC 103 ms
77,592 KB
testcase_11 AC 93 ms
71,516 KB
testcase_12 AC 148 ms
79,428 KB
testcase_13 AC 123 ms
78,332 KB
testcase_14 AC 124 ms
78,424 KB
testcase_15 AC 122 ms
78,120 KB
testcase_16 AC 92 ms
71,896 KB
testcase_17 AC 70 ms
71,244 KB
testcase_18 AC 88 ms
71,560 KB
testcase_19 AC 123 ms
78,036 KB
testcase_20 AC 90 ms
71,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")

n,m,x,y,z = list(map(int, input().split()))
V = "Handicapped"
a = list(map(int, input().split()))
b = [a[i] for i in range(n) if a[i]>=x]
a = [a[i]-z for i in range(n) if x>a[i]>y]
if len(b)>m:
    print(V)
else:
    from collections import defaultdict
    target = z*len(b) - sum(b)
    dp = defaultdict(int)
    dp[0,len(b)] = 1
    for i in range(len(a)):
        v = a[i]
        ndp = defaultdict(int)
        for k,num in dp:
            ndp[k,num] += dp[k,num]
            ndp[k+v,num+1] += dp[k,num]
        dp = ndp
#         print(dp, v)
    ans = 0
    for k,num in dp:
        if k==target and 0<num<=m:
            ans += dp[k,num]
    print(ans)
0