結果

問題 No.1457 ツブ消ししとるなHard
ユーザー ああいいああいい
提出日時 2022-06-03 07:51:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 961 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 81,564 KB
実行使用メモリ 94,600 KB
最終ジャッジ日時 2023-10-21 01:25:43
合計ジャッジ時間 2,866 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
61,656 KB
testcase_01 AC 36 ms
53,352 KB
testcase_02 AC 47 ms
61,656 KB
testcase_03 AC 37 ms
53,348 KB
testcase_04 AC 186 ms
91,444 KB
testcase_05 AC 175 ms
90,204 KB
testcase_06 AC 193 ms
94,600 KB
testcase_07 AC 38 ms
53,380 KB
testcase_08 AC 37 ms
53,380 KB
testcase_09 AC 59 ms
69,900 KB
testcase_10 AC 58 ms
69,900 KB
testcase_11 AC 51 ms
65,780 KB
testcase_12 AC 103 ms
79,072 KB
testcase_13 AC 79 ms
76,732 KB
testcase_14 AC 52 ms
65,796 KB
testcase_15 AC 81 ms
76,372 KB
testcase_16 AC 80 ms
77,632 KB
testcase_17 AC 36 ms
53,380 KB
testcase_18 AC 42 ms
59,600 KB
testcase_19 AC 176 ms
89,424 KB
testcase_20 AC 45 ms
59,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,X,Y,Z = map(int,input().split())
A = list(map(int,input().split()))

l = []
count = 0
s = 0
for a in A:
    if a >= X:
        count += 1
        s += a - Z
    elif a > Y:
        l.append(a - Z)
n = len(l)
import sys
if count > M:
    print('Handicapped')
    exit()
if count == M:
    if s == 0:
        print(1)
    else:
        print(0)
    exit()
    
C = 2500 + 10
base = 2500 + 5
dp = [[0] * (2 * C) for _ in range(M - count + 1)]
dp[0][base + s] = 1
for i in range(n):
    a = l[i]
    nx = [[0] * (2 * C) for _ in range(M - count + 1)]
    for j in range(M - count):
        u = dp[j]
        v = nx[j + 1]
        for k in range(2 * C):
            if 0 <= k + a < 2 * C:
                v[k + a] += u[k]
    for j in range(1 + M - count):
        u = dp[j]
        v = nx[j]
        for k in range(2 * C):
            v[k] += u[k]
    dp = nx
ans = 0
for j in range(M - count + 1):
    ans += dp[j][base]
if count == 0:
    ans -= 1
print(ans)
0