結果

問題 No.1861 Required Number
ユーザー roarisroaris
提出日時 2022-03-04 21:56:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 661 bytes
コンパイル時間 577 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 144,288 KB
最終ジャッジ日時 2023-09-26 03:29:05
合計ジャッジ時間 24,863 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
71,536 KB
testcase_01 WA -
testcase_02 AC 92 ms
71,576 KB
testcase_03 AC 490 ms
144,120 KB
testcase_04 AC 462 ms
144,200 KB
testcase_05 AC 92 ms
71,696 KB
testcase_06 AC 93 ms
71,752 KB
testcase_07 AC 98 ms
76,884 KB
testcase_08 AC 104 ms
77,600 KB
testcase_09 WA -
testcase_10 AC 103 ms
77,332 KB
testcase_11 AC 105 ms
77,392 KB
testcase_12 WA -
testcase_13 AC 106 ms
77,504 KB
testcase_14 AC 106 ms
77,324 KB
testcase_15 AC 104 ms
77,344 KB
testcase_16 WA -
testcase_17 AC 104 ms
77,264 KB
testcase_18 AC 106 ms
77,464 KB
testcase_19 AC 110 ms
77,584 KB
testcase_20 AC 109 ms
77,756 KB
testcase_21 AC 104 ms
77,248 KB
testcase_22 AC 105 ms
77,496 KB
testcase_23 AC 104 ms
77,232 KB
testcase_24 AC 263 ms
99,172 KB
testcase_25 AC 509 ms
144,232 KB
testcase_26 AC 164 ms
78,020 KB
testcase_27 AC 257 ms
98,164 KB
testcase_28 AC 277 ms
98,468 KB
testcase_29 AC 208 ms
94,228 KB
testcase_30 AC 124 ms
78,100 KB
testcase_31 AC 503 ms
144,288 KB
testcase_32 AC 131 ms
78,048 KB
testcase_33 AC 379 ms
121,168 KB
testcase_34 AC 420 ms
121,448 KB
testcase_35 AC 418 ms
121,048 KB
testcase_36 AC 209 ms
95,572 KB
testcase_37 AC 266 ms
98,120 KB
testcase_38 AC 430 ms
121,060 KB
testcase_39 AC 289 ms
98,176 KB
testcase_40 AC 503 ms
144,028 KB
testcase_41 AC 483 ms
143,424 KB
testcase_42 AC 406 ms
121,040 KB
testcase_43 AC 266 ms
98,184 KB
testcase_44 AC 87 ms
71,764 KB
04_evil_1.txt TLE -
04_evil_2.txt TLE -
04_evil_3.txt TLE -
04_evil_4.txt MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import *

N, K = map(int, input().split())
A = list(map(int, input().split()))
dp1 = [False]*(K+1)
dp1[0] = True
dp2 = [[False]*(K+1) for _ in range(N+1)]
dp2[0][0] = True

for i in range(N):
    for j in range(K+1):
        if dp2[i][j]:
            dp2[i+1][j] = True
            
            if j+A[N-1-i]<=K:
                dp2[i+1][j+A[N-1-i]] = True

ans = 0

for i in range(N):
    for j in range(K+1):
        if dp1[j] and dp2[N-1-i][K-j]:
            break
    else:
        ans += 1
    
    for j in range(K, -1, -1):
        if dp1[j] and j+A[i]<=K:
            dp1[j+A[i]] = True

print(ans)
0