結果
| 問題 |
No.1457 ツブ消ししとるなHard
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-31 22:04:34 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 260 ms / 2,000 ms |
| コード長 | 839 bytes |
| コンパイル時間 | 347 ms |
| コンパイル使用メモリ | 82,396 KB |
| 実行使用メモリ | 100,584 KB |
| 最終ジャッジ日時 | 2024-12-15 18:52:31 |
| 合計ジャッジ時間 | 2,516 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 |
ソースコード
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)