結果

問題 No.1457 ツブ消ししとるなHard
コンテスト
ユーザー ID 21712
提出日時 2026-05-25 04:21:25
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 1,274 ms / 2,000 ms
コード長 638 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 717 ms
コンパイル使用メモリ 20,956 KB
実行使用メモリ 15,488 KB
最終ジャッジ日時 2026-05-25 21:40:54
合計ジャッジ時間 12,498 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_1
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def solve():
	N,M,X,Y,Z = map(int,input().split())
	keeps = []
	k_sum = 0
	others = []
	o_sum = 0
	for a in map(int, input().split()):
		if a >= X:
			keeps.append(a)
			k_sum += a
		elif a > Y:
			others.append(a)
			o_sum += a
	
	if len(keeps) > M:
		print("Handicapped")
		return
	
	dp = [[0]*(o_sum+1) for _ in range(M-len(keeps)+1)]
	
	dp[0][0] = 1
	for t in others:
		for i in range(len(dp)-2,-1,-1):
			tmp = dp[i+1]
			for s,c in enumerate(dp[i]):
				if s+t < len(tmp):
					tmp[s+t] += c

	ans = 0
	for u,ss in enumerate(dp):
		p = Z*(u+len(keeps)) - k_sum
		if 0 < p and p < len(ss):
			ans += ss[p]
	
	print(ans)
	

solve()
		
0