結果

問題 No.1457 ツブ消ししとるなHard
ユーザー 👑 rin204rin204
提出日時 2022-01-18 04:36:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 619 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 86,844 KB
実行使用メモリ 76,104 KB
最終ジャッジ日時 2023-08-15 07:22:17
合計ジャッジ時間 2,572 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,012 KB
testcase_01 AC 61 ms
71,008 KB
testcase_02 AC 63 ms
71,248 KB
testcase_03 AC 63 ms
70,992 KB
testcase_04 AC 67 ms
76,036 KB
testcase_05 AC 69 ms
75,940 KB
testcase_06 AC 89 ms
75,604 KB
testcase_07 AC 61 ms
71,004 KB
testcase_08 AC 63 ms
71,004 KB
testcase_09 AC 69 ms
75,944 KB
testcase_10 AC 70 ms
76,104 KB
testcase_11 AC 62 ms
71,024 KB
testcase_12 AC 74 ms
76,016 KB
testcase_13 AC 69 ms
75,964 KB
testcase_14 AC 69 ms
75,596 KB
testcase_15 AC 70 ms
75,944 KB
testcase_16 AC 62 ms
71,048 KB
testcase_17 AC 65 ms
71,152 KB
testcase_18 AC 65 ms
71,016 KB
testcase_19 AC 71 ms
75,948 KB
testcase_20 AC 64 ms
71,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m, x, y, z = map(int, input().split())
A = list(map(int, input().split()))
B = []
tot = 0
cnt = 0
for a in A:
    if a <= y:
        pass
    elif a >= x:
        tot += a - z
        cnt += 1
    else:
        B.append(a - z)
if cnt > m:
    print("Handicapped")
    exit()
n = len(B)
dp = {}
for i in range(n + 1):
    dp[i] = {}

dp[0][tot] = 1
for i, b in enumerate(B, 1):
    for j in range(i - 1, -1, -1):
        for k, v in dp[j].items():
            dp[j + 1][k + b] = dp[j + 1].get(k + b, 0) + v

ans = 0
if cnt == 0:
    ans -= 1
for i in range(min(n, m - cnt) + 1):
    ans += dp[i].get(0, 0)
print(ans)
0