結果

問題 No.1861 Required Number
ユーザー AEnAEn
提出日時 2022-11-22 23:52:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 714 bytes
コンパイル時間 382 ms
コンパイル使用メモリ 81,812 KB
実行使用メモリ 375,144 KB
最終ジャッジ日時 2023-10-24 14:36:52
合計ジャッジ時間 20,009 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,612 KB
testcase_01 AC 41 ms
59,764 KB
testcase_02 AC 37 ms
53,612 KB
testcase_03 AC 254 ms
155,292 KB
testcase_04 AC 255 ms
155,240 KB
testcase_05 AC 37 ms
53,612 KB
testcase_06 AC 40 ms
53,612 KB
testcase_07 AC 43 ms
59,768 KB
testcase_08 AC 50 ms
64,180 KB
testcase_09 AC 43 ms
59,776 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 42 ms
59,776 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 41 ms
59,772 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 434 ms
188,588 KB
testcase_25 AC 1,039 ms
360,264 KB
testcase_26 AC 209 ms
119,556 KB
testcase_27 AC 385 ms
169,356 KB
testcase_28 AC 421 ms
174,076 KB
testcase_29 AC 277 ms
142,984 KB
testcase_30 AC 98 ms
80,900 KB
testcase_31 AC 1,036 ms
356,864 KB
testcase_32 AC 134 ms
96,780 KB
testcase_33 AC 675 ms
236,972 KB
testcase_34 AC 877 ms
325,308 KB
testcase_35 AC 880 ms
326,200 KB
testcase_36 AC 281 ms
143,816 KB
testcase_37 AC 414 ms
175,696 KB
testcase_38 AC 908 ms
326,956 KB
testcase_39 AC 473 ms
189,108 KB
testcase_40 AC 1,054 ms
375,144 KB
testcase_41 AC 1,000 ms
358,124 KB
testcase_42 AC 758 ms
253,068 KB
testcase_43 AC 440 ms
181,264 KB
testcase_44 WA -
04_evil_1.txt MLE -
04_evil_2.txt MLE -
04_evil_3.txt MLE -
04_evil_4.txt MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())
A = list(map(int, input().split()))

dp = [[0]*(K+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(1,N+1):
    a = A[i-1]
    for j in range(K+1):
        dp[i][j] |= dp[i-1][j]
        if j+a<=K:
            dp[i][j+a] |= dp[i-1][j]

if dp[-1][-1]==0:
    exit(print(-1))

dpr = [set() for _ in range(N+1)]
dpr[-1].add(K)
ans = 0
for i in range(N,0,-1):
    a = A[i-1]
    c1, c2 = 0, 0
    for num in dpr[i]:
        if dp[i-1][num]>0:
            c1 += 1
            dpr[i-1].add(num)
        if num-a>=0 and dp[i-1][num-a]>0:
            c2 += 1
            dpr[i-1].add(num-a)
    l = len(dpr[i])
    if (c1==l and c2==0) or (c1==0 and c2==l):
        ans += 1
print(ans)

0