結果

問題 No.1861 Required Number
ユーザー chineristACchineristAC
提出日時 2022-03-04 22:31:54
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 808 bytes
コンパイル時間 550 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 849,304 KB
最終ジャッジ日時 2023-09-26 03:44:35
合計ジャッジ時間 7,697 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
74,736 KB
testcase_01 AC 110 ms
74,388 KB
testcase_02 AC 109 ms
74,364 KB
testcase_03 AC 725 ms
84,276 KB
testcase_04 AC 726 ms
84,164 KB
testcase_05 AC 110 ms
74,600 KB
testcase_06 AC 109 ms
74,800 KB
testcase_07 AC 117 ms
79,096 KB
testcase_08 AC 137 ms
80,596 KB
testcase_09 AC 110 ms
74,224 KB
testcase_10 AC 125 ms
80,600 KB
testcase_11 AC 125 ms
80,108 KB
testcase_12 AC 107 ms
74,560 KB
testcase_13 AC 142 ms
80,476 KB
testcase_14 AC 116 ms
79,124 KB
testcase_15 AC 123 ms
80,664 KB
testcase_16 AC 110 ms
74,544 KB
testcase_17 AC 118 ms
78,816 KB
testcase_18 AC 137 ms
80,492 KB
testcase_19 AC 224 ms
80,852 KB
testcase_20 AC 169 ms
80,688 KB
testcase_21 AC 127 ms
80,680 KB
testcase_22 AC 184 ms
80,648 KB
testcase_23 AC 118 ms
79,284 KB
testcase_24 MLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
04_evil_1.txt -- -
04_evil_2.txt -- -
04_evil_3.txt -- -
04_evil_4.txt -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import log,gcd

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

N,K = mi()
A = li()

assert N <= 10**4
assert K <= 10**3

dp = [0 for i in range(N+1)]
dp[0] = 1
for i in range(N):
    dp[i+1] = dp[i]|(dp[i]<<A[i])

dp_back = [0 for i in range(N+1)]
dp_back[N] = 1
for i in range(N)[::-1]:
    dp_back[i] = dp_back[i+1]|(dp_back[i+1]<<A[i])

if dp[-1]>>K & 1 == 0:
    exit(print(-1))

need = 0
for i in range(N):
    flag = True
    for k in range(K+1):
        if dp[i]>>k & 1:
            if dp_back[i+1]>>(K-k) & 1:
                flag = False
    if flag:
        need += 1


print(need)
0