結果

問題 No.1861 Required Number
ユーザー shiomusubi496shiomusubi496
提出日時 2022-03-02 11:42:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 809 ms / 2,500 ms
コード長 851 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 226,580 KB
最終ジャッジ日時 2023-09-26 03:09:40
合計ジャッジ時間 25,433 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,368 KB
testcase_01 AC 76 ms
75,916 KB
testcase_02 AC 69 ms
71,444 KB
testcase_03 AC 752 ms
226,356 KB
testcase_04 AC 809 ms
226,580 KB
testcase_05 AC 70 ms
71,500 KB
testcase_06 AC 70 ms
71,572 KB
testcase_07 AC 79 ms
75,868 KB
testcase_08 AC 84 ms
76,020 KB
testcase_09 AC 77 ms
75,780 KB
testcase_10 AC 81 ms
75,924 KB
testcase_11 AC 83 ms
76,044 KB
testcase_12 AC 79 ms
76,068 KB
testcase_13 AC 83 ms
76,036 KB
testcase_14 AC 82 ms
75,892 KB
testcase_15 AC 82 ms
76,092 KB
testcase_16 AC 76 ms
75,952 KB
testcase_17 AC 82 ms
76,068 KB
testcase_18 AC 83 ms
76,096 KB
testcase_19 AC 84 ms
76,204 KB
testcase_20 AC 82 ms
76,220 KB
testcase_21 AC 80 ms
76,044 KB
testcase_22 AC 83 ms
76,112 KB
testcase_23 AC 80 ms
75,992 KB
testcase_24 AC 288 ms
130,792 KB
testcase_25 AC 557 ms
203,728 KB
testcase_26 AC 168 ms
89,900 KB
testcase_27 AC 286 ms
125,452 KB
testcase_28 AC 294 ms
133,792 KB
testcase_29 AC 209 ms
109,368 KB
testcase_30 AC 116 ms
84,756 KB
testcase_31 AC 563 ms
203,736 KB
testcase_32 AC 134 ms
88,536 KB
testcase_33 AC 449 ms
171,696 KB
testcase_34 AC 476 ms
180,968 KB
testcase_35 AC 481 ms
180,424 KB
testcase_36 AC 219 ms
111,628 KB
testcase_37 AC 288 ms
131,140 KB
testcase_38 AC 530 ms
193,220 KB
testcase_39 AC 318 ms
134,720 KB
testcase_40 AC 571 ms
203,352 KB
testcase_41 AC 546 ms
204,004 KB
testcase_42 AC 464 ms
180,560 KB
testcase_43 AC 295 ms
133,004 KB
testcase_44 AC 70 ms
71,568 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] * (K + 1) for _ in range(N + 1)]
dpr = [[False] * (K + 1) for _ in range(N + 1)]
dpl[0][0] = dpr[N][0] = True

for i in range(N):
    for j in range(K + 1):
        dpl[i + 1][j] = dpl[i][j]
    for j in range(0, K - A[i] + 1):
        if dpl[i][j]:
            dpl[i + 1][j + A[i]] = True
for i in range(N - 1, -1, -1):
    for j in range(K + 1):
        dpr[i][j] = dpr[i + 1][j]
    for j in range(0, K - A[i] + 1):
        if dpr[i + 1][j]:
            dpr[i][j + A[i]] = True
if not dpl[N][K]:
    print(-1)
else:
    ans = 0
    for i in range(N):
        not_use = True
        for j in range(K + 1):
            if dpl[i][j] and dpr[i + 1][K - j]:
                not_use = False
                break
        if not_use:
            ans += 1
    print(ans)
0