結果

問題 No.1861 Required Number
ユーザー SidewaysOwlSidewaysOwl
提出日時 2022-03-04 22:17:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,591 ms / 2,500 ms
コード長 984 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 177,912 KB
最終ジャッジ日時 2023-09-26 03:41:49
合計ジャッジ時間 34,809 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
75,944 KB
testcase_01 AC 77 ms
83,112 KB
testcase_02 AC 71 ms
76,052 KB
testcase_03 AC 1,591 ms
172,464 KB
testcase_04 AC 1,534 ms
177,912 KB
testcase_05 AC 70 ms
76,008 KB
testcase_06 AC 70 ms
71,424 KB
testcase_07 AC 78 ms
76,116 KB
testcase_08 AC 85 ms
76,168 KB
testcase_09 AC 78 ms
76,116 KB
testcase_10 AC 111 ms
77,536 KB
testcase_11 AC 98 ms
77,232 KB
testcase_12 AC 88 ms
76,456 KB
testcase_13 AC 107 ms
77,192 KB
testcase_14 AC 88 ms
76,220 KB
testcase_15 AC 95 ms
76,432 KB
testcase_16 AC 75 ms
76,276 KB
testcase_17 AC 97 ms
77,004 KB
testcase_18 AC 112 ms
77,552 KB
testcase_19 AC 117 ms
77,560 KB
testcase_20 AC 113 ms
77,584 KB
testcase_21 AC 97 ms
76,628 KB
testcase_22 AC 112 ms
77,688 KB
testcase_23 AC 95 ms
76,624 KB
testcase_24 AC 485 ms
97,904 KB
testcase_25 AC 1,123 ms
143,540 KB
testcase_26 AC 247 ms
80,176 KB
testcase_27 AC 456 ms
86,540 KB
testcase_28 AC 527 ms
93,128 KB
testcase_29 AC 324 ms
81,276 KB
testcase_30 AC 139 ms
77,764 KB
testcase_31 AC 1,224 ms
150,184 KB
testcase_32 AC 168 ms
78,120 KB
testcase_33 AC 803 ms
110,592 KB
testcase_34 AC 905 ms
122,852 KB
testcase_35 AC 1,001 ms
122,520 KB
testcase_36 AC 316 ms
81,464 KB
testcase_37 AC 467 ms
86,772 KB
testcase_38 AC 964 ms
128,852 KB
testcase_39 AC 541 ms
91,920 KB
testcase_40 AC 1,237 ms
144,404 KB
testcase_41 AC 1,063 ms
140,624 KB
testcase_42 AC 874 ms
116,288 KB
testcase_43 AC 509 ms
87,876 KB
testcase_44 AC 71 ms
71,352 KB
04_evil_1.txt TLE -
04_evil_2.txt TLE -
04_evil_3.txt TLE -
04_evil_4.txt TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k = map(int,input().split())
a = list(map(int,input().split()))
max_k = k+1
dp = [set() for _ in range(max_k)]
dp[0].add(0)

for i in range(n):
    aa = a[i]
    n_dp =  [set() for _ in range(max_k)]
    for j in range(max_k):
        if n_dp[j]:
            pass
#             p = set()
#             for x in dp[j]:
#                 if x in n_dp[j]:
#                     p.add(x)
#             n_dp[j] = p
        else:
            for x in dp[j]:
                n_dp[j].add(x)
            
        if dp[j]:
            if aa + j <= k:
                if dp[aa + j]:
                    p = set()
                    for x in dp[aa + j]:
                        if x in dp[j]:
                            p.add(x)
                    n_dp[aa + j] = p
                else:
                    n_dp[aa+j].add(i+1)
                    for x in dp[j]:
                        n_dp[aa+j].add(x)
    dp = n_dp
#     print(dp)
if dp[-1]:
    print(len(dp[-1])-1)
else:
    print(-1)
0