結果

問題 No.1861 Required Number
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-03-04 22:23:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 680 bytes
コンパイル時間 589 ms
コンパイル使用メモリ 87,200 KB
実行使用メモリ 237,588 KB
最終ジャッジ日時 2023-09-26 03:42:08
合計ジャッジ時間 18,374 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 74 ms
75,648 KB
testcase_02 AC 72 ms
71,408 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 71 ms
71,500 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 73 ms
75,604 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 77 ms
75,916 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 77 ms
75,604 KB
testcase_17 AC 88 ms
75,976 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
04_evil_1.txt MLE -
04_evil_2.txt MLE -
04_evil_3.txt MLE -
04_evil_4.txt MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

cand = [[] for i in range(2)]
for ind in range(2):

    dp = [[-2]*(k+1) for i in range(n+1)]
    dp[0][0] = -1
    for i,a in enumerate(A):
        for j in range(k+1):
            if dp[i][j] == -2:
                continue
            dp[i+1][j] = max(dp[i+1][j],dp[i][j])
            if j+a <= k:
                dp[i+1][j+a] = i

    if dp[-1][k] == -2:
        print(-1)
        exit()

    now = k
    for i in range(n+1)[::-1]:
        cand[ind].append(dp[i][now])
        now -= A[dp[i][now]]
        if now == 0:
            break
    A = A[::-1]

s1 = set(cand[1])
s2 = set(cand[0])
print(len(s1 & s2))
0