結果

問題 No.1861 Required Number
ユーザー 👑 KazunKazun
提出日時 2022-03-04 21:42:25
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 566 bytes
コンパイル時間 1,722 ms
コンパイル使用メモリ 87,036 KB
実行使用メモリ 77,188 KB
最終ジャッジ日時 2023-09-26 03:21:34
合計ジャッジ時間 8,116 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,412 KB
testcase_01 AC 78 ms
75,140 KB
testcase_02 AC 75 ms
71,388 KB
testcase_03 AC 201 ms
76,544 KB
testcase_04 WA -
testcase_05 AC 71 ms
71,400 KB
testcase_06 AC 71 ms
71,104 KB
testcase_07 AC 76 ms
75,108 KB
testcase_08 AC 77 ms
75,904 KB
testcase_09 AC 75 ms
75,084 KB
testcase_10 AC 78 ms
75,452 KB
testcase_11 WA -
testcase_12 AC 76 ms
75,304 KB
testcase_13 AC 79 ms
75,360 KB
testcase_14 WA -
testcase_15 AC 78 ms
75,360 KB
testcase_16 AC 75 ms
75,104 KB
testcase_17 AC 78 ms
75,464 KB
testcase_18 AC 80 ms
75,440 KB
testcase_19 AC 79 ms
75,408 KB
testcase_20 AC 81 ms
75,348 KB
testcase_21 AC 79 ms
75,380 KB
testcase_22 AC 84 ms
75,572 KB
testcase_23 AC 80 ms
75,512 KB
testcase_24 AC 109 ms
76,268 KB
testcase_25 AC 149 ms
75,980 KB
testcase_26 AC 96 ms
76,400 KB
testcase_27 AC 110 ms
76,456 KB
testcase_28 AC 114 ms
76,384 KB
testcase_29 AC 113 ms
77,188 KB
testcase_30 AC 95 ms
76,140 KB
testcase_31 AC 147 ms
76,228 KB
testcase_32 AC 91 ms
76,328 KB
testcase_33 AC 126 ms
76,428 KB
testcase_34 AC 135 ms
76,168 KB
testcase_35 AC 136 ms
76,204 KB
testcase_36 AC 104 ms
76,452 KB
testcase_37 AC 110 ms
76,344 KB
testcase_38 AC 166 ms
77,184 KB
testcase_39 AC 119 ms
76,424 KB
testcase_40 AC 150 ms
76,164 KB
testcase_41 AC 178 ms
77,016 KB
testcase_42 AC 134 ms
76,148 KB
testcase_43 AC 115 ms
76,428 KB
testcase_44 AC 77 ms
71,420 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):
    A=["*"]+A
    DP=[-1]*(K+1); DP[0]=0

    for i,a in enumerate(A[1:],1):
        for y in range(K,a-1,-1):
            if DP[y-a]>=0 and DP[y]==-1:
                DP[y]=i
    if DP[K]==-1:
        return None

    X=[]; x=K
    while x>0:
        X.append(DP[x])
        x-=A[DP[x]]
    return X
#==================================================
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()

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

P=f(A)
if P==None:
    exit(print(-1))

Q=[N-k+1 for k in f(A[::-1])]

print(len(set(P)&set(Q)))
0