結果

問題 No.1457 ツブ消ししとるなHard
ユーザー 👑 rin204rin204
提出日時 2022-01-18 04:32:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 591 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 76,352 KB
最終ジャッジ日時 2023-08-15 07:22:13
合計ジャッジ時間 3,312 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
70,916 KB
testcase_01 AC 62 ms
71,084 KB
testcase_02 AC 62 ms
71,020 KB
testcase_03 AC 63 ms
71,016 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 61 ms
71,044 KB
testcase_08 AC 64 ms
70,740 KB
testcase_09 AC 63 ms
71,004 KB
testcase_10 AC 63 ms
71,072 KB
testcase_11 WA -
testcase_12 AC 72 ms
76,128 KB
testcase_13 WA -
testcase_14 AC 69 ms
75,876 KB
testcase_15 AC 72 ms
75,600 KB
testcase_16 WA -
testcase_17 AC 62 ms
71,156 KB
testcase_18 AC 60 ms
70,864 KB
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

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][0] = 1
for i, b in enumerate(B):
    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
for i in range(min(n, m - cnt) + 1):
    ans += dp[i].get(-tot, 0)
print(ans)
0