結果

問題 No.1457 ツブ消ししとるなHard
ユーザー titiatitia
提出日時 2021-03-31 22:36:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 924 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 224 ms
コンパイル使用メモリ 10,924 KB
実行使用メモリ 13,128 KB
最終ジャッジ日時 2023-08-22 03:14:41
合計ジャッジ時間 2,901 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
8,660 KB
testcase_01 AC 16 ms
8,212 KB
testcase_02 AC 21 ms
8,712 KB
testcase_03 AC 21 ms
8,792 KB
testcase_04 AC 26 ms
8,684 KB
testcase_05 AC 25 ms
8,744 KB
testcase_06 AC 924 ms
13,128 KB
testcase_07 AC 16 ms
8,224 KB
testcase_08 AC 16 ms
8,156 KB
testcase_09 AC 25 ms
8,732 KB
testcase_10 AC 26 ms
8,772 KB
testcase_11 AC 22 ms
8,716 KB
testcase_12 AC 198 ms
10,084 KB
testcase_13 AC 54 ms
9,068 KB
testcase_14 AC 25 ms
8,656 KB
testcase_15 AC 47 ms
9,048 KB
testcase_16 AC 21 ms
8,760 KB
testcase_17 AC 16 ms
8,260 KB
testcase_18 AC 21 ms
8,708 KB
testcase_19 AC 65 ms
8,992 KB
testcase_20 AC 20 ms
8,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

B=[]
C=[]

for a in A:
    if a>=X:
        C.append(a)
    elif a>Y:
        B.append(a)
        
if len(C)>M:
    print("Handicapped")
    exit()
    
B=sorted(B)
B=[b-Z for b in B]
C=[c-Z for c in C]
S=sum(C)


from collections import defaultdict
DP=defaultdict(int)
DP[(0,0)]=1
import copy

for b in B:
    NDP=copy.deepcopy(DP)

    for d,k in DP:
        if k+1<=M:
            NDP[(d+b,k+1)]+=DP[d,k]

    DP=NDP

ANS=0
for i,j in DP:
    if i==-S and j!=0:
        ANS+=DP[(i,j)]

print(ANS)





0