結果

問題 No.1861 Required Number
ユーザー 👑 KazunKazun
提出日時 2022-03-04 23:47:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 505 ms / 2,500 ms
コード長 537 bytes
コンパイル時間 893 ms
コンパイル使用メモリ 87,208 KB
実行使用メモリ 329,912 KB
最終ジャッジ日時 2023-09-26 03:08:40
合計ジャッジ時間 11,947 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,184 KB
testcase_01 AC 73 ms
75,532 KB
testcase_02 AC 71 ms
71,428 KB
testcase_03 AC 505 ms
315,280 KB
testcase_04 AC 499 ms
314,956 KB
testcase_05 AC 74 ms
71,344 KB
testcase_06 AC 73 ms
71,400 KB
testcase_07 AC 80 ms
76,236 KB
testcase_08 AC 82 ms
76,464 KB
testcase_09 AC 76 ms
75,536 KB
testcase_10 AC 81 ms
76,136 KB
testcase_11 AC 78 ms
76,192 KB
testcase_12 AC 75 ms
75,476 KB
testcase_13 AC 77 ms
76,140 KB
testcase_14 AC 78 ms
75,964 KB
testcase_15 AC 78 ms
76,056 KB
testcase_16 AC 78 ms
76,324 KB
testcase_17 AC 78 ms
76,036 KB
testcase_18 AC 79 ms
76,212 KB
testcase_19 AC 80 ms
76,044 KB
testcase_20 AC 77 ms
76,088 KB
testcase_21 AC 76 ms
76,192 KB
testcase_22 AC 76 ms
76,132 KB
testcase_23 AC 76 ms
76,192 KB
testcase_24 AC 226 ms
177,948 KB
testcase_25 AC 442 ms
326,828 KB
testcase_26 AC 142 ms
110,316 KB
testcase_27 AC 203 ms
153,952 KB
testcase_28 AC 227 ms
177,548 KB
testcase_29 AC 165 ms
121,652 KB
testcase_30 AC 101 ms
83,108 KB
testcase_31 AC 448 ms
329,912 KB
testcase_32 AC 104 ms
82,924 KB
testcase_33 AC 318 ms
245,520 KB
testcase_34 AC 392 ms
301,028 KB
testcase_35 AC 393 ms
304,708 KB
testcase_36 AC 167 ms
123,476 KB
testcase_37 AC 231 ms
176,372 KB
testcase_38 AC 401 ms
309,020 KB
testcase_39 AC 254 ms
199,724 KB
testcase_40 AC 442 ms
328,580 KB
testcase_41 AC 419 ms
317,152 KB
testcase_42 AC 368 ms
288,012 KB
testcase_43 AC 229 ms
176,360 KB
testcase_44 AC 70 ms
71,196 KB
04_evil_1.txt RE -
04_evil_2.txt RE -
04_evil_3.txt RE -
04_evil_4.txt RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(A):
    DP=[[0]*(K+1) for _ in range(N+2)]
    DP[0][0]=1

    for i,a in enumerate(A,1):
        D=DP[i-1].copy()
        for y in range(K,a-1,-1):
            D[y]|=D[y-a]
        DP[i]=D
    DP[-1][0]=1
    return DP

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

assert (N<=10**4) and (K<=10**3)

X=f(A)
Y=f(A[::-1])[::-1]

if X[N][K]==0:
    Ans=-1
else:
    Ans=0
    for i in range(1,N+1):
        flag=1
        for x in range(K+1):
            flag&=~(X[i-1][x]&Y[i+1][K-x])
        Ans+=flag

print(Ans)
0