結果

問題 No.1861 Required Number
ユーザー lloyzlloyz
提出日時 2023-07-31 01:26:35
言語 PyPy3
(7.3.15)
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 899 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 82,332 KB
実行使用メモリ 904,716 KB
最終ジャッジ日時 2024-04-18 02:29:44
合計ジャッジ時間 27,890 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 AC 42 ms
60,880 KB
testcase_02 AC 35 ms
52,680 KB
testcase_03 AC 661 ms
234,604 KB
testcase_04 AC 705 ms
234,672 KB
testcase_05 AC 36 ms
52,672 KB
testcase_06 AC 37 ms
52,904 KB
testcase_07 AC 44 ms
60,928 KB
testcase_08 AC 53 ms
65,816 KB
testcase_09 AC 42 ms
59,488 KB
testcase_10 AC 50 ms
63,456 KB
testcase_11 AC 51 ms
64,724 KB
testcase_12 AC 47 ms
62,228 KB
testcase_13 AC 50 ms
63,364 KB
testcase_14 AC 50 ms
64,016 KB
testcase_15 AC 50 ms
64,652 KB
testcase_16 AC 44 ms
60,548 KB
testcase_17 AC 50 ms
63,128 KB
testcase_18 AC 51 ms
63,944 KB
testcase_19 AC 53 ms
64,752 KB
testcase_20 AC 53 ms
64,624 KB
testcase_21 AC 49 ms
63,540 KB
testcase_22 AC 52 ms
63,976 KB
testcase_23 AC 53 ms
65,184 KB
testcase_24 AC 303 ms
128,524 KB
testcase_25 AC 646 ms
212,744 KB
testcase_26 AC 179 ms
99,500 KB
testcase_27 AC 282 ms
123,668 KB
testcase_28 AC 307 ms
126,056 KB
testcase_29 AC 205 ms
101,812 KB
testcase_30 AC 99 ms
80,848 KB
testcase_31 AC 657 ms
214,824 KB
testcase_32 AC 118 ms
82,588 KB
testcase_33 AC 482 ms
168,824 KB
testcase_34 AC 567 ms
188,292 KB
testcase_35 AC 558 ms
190,076 KB
testcase_36 AC 202 ms
102,264 KB
testcase_37 AC 296 ms
123,144 KB
testcase_38 AC 580 ms
191,816 KB
testcase_39 AC 355 ms
140,088 KB
testcase_40 AC 654 ms
213,448 KB
testcase_41 AC 658 ms
206,728 KB
testcase_42 AC 510 ms
168,780 KB
testcase_43 AC 304 ms
123,780 KB
testcase_44 AC 35 ms
53,000 KB
04_evil_1.txt TLE -
04_evil_2.txt TLE -
04_evil_3.txt TLE -
04_evil_4.txt MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
A = list(map(int, input().split()))

DPl = [[False for _ in range(k + 1)] for _ in range(n + 1)]
DPr = [[False for _ in range(k + 1)] for _ in range(n + 1)]
DPl[0][0] = True
DPr[n][0] = True
for i in range(n):
    a = A[i]
    for j in range(k + 1):
        if DPl[i][j] > 0:
            DPl[i + 1][j] |= DPl[i][j]
            if j + a <= k:
                DPl[i + 1][j + a] |= DPl[i][j]
for i in range(n - 1, -1, -1):
    a = A[i]
    for j in range(k + 1):
        if DPr[i + 1][j] > 0:
            DPr[i][j] |= DPr[i + 1][j]
            if j + a <= k:
                DPr[i][j + a] |= DPr[i + 1][j]
ans = 0
if DPl[n][k]:
    for i in range(n):
        flag = True
        for j in range(k + 1):
            if DPl[i][j] and DPr[i + 1][k - j]:
                flag = False
                break
        if flag:
            ans += 1
else:
    ans = -1
print(ans)
0