結果

問題 No.1538 引きこもりさんは引き算が得意。
ユーザー shotoyooshotoyoo
提出日時 2021-06-17 00:33:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 946 bytes
コンパイル時間 1,316 ms
コンパイル使用メモリ 86,920 KB
実行使用メモリ 113,716 KB
最終ジャッジ日時 2023-08-30 05:50:27
合計ジャッジ時間 9,627 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,576 KB
testcase_01 AC 70 ms
71,176 KB
testcase_02 AC 78 ms
71,320 KB
testcase_03 AC 77 ms
71,320 KB
testcase_04 AC 74 ms
71,368 KB
testcase_05 AC 73 ms
71,268 KB
testcase_06 AC 73 ms
71,200 KB
testcase_07 AC 70 ms
71,372 KB
testcase_08 AC 74 ms
71,396 KB
testcase_09 AC 74 ms
71,176 KB
testcase_10 AC 73 ms
71,176 KB
testcase_11 WA -
testcase_12 AC 72 ms
71,488 KB
testcase_13 AC 71 ms
71,520 KB
testcase_14 AC 86 ms
76,452 KB
testcase_15 AC 75 ms
71,244 KB
testcase_16 AC 75 ms
71,240 KB
testcase_17 AC 70 ms
71,356 KB
testcase_18 AC 74 ms
71,256 KB
testcase_19 AC 75 ms
71,068 KB
testcase_20 AC 74 ms
71,524 KB
testcase_21 AC 75 ms
71,356 KB
testcase_22 AC 75 ms
71,324 KB
testcase_23 AC 69 ms
71,404 KB
testcase_24 AC 72 ms
71,372 KB
testcase_25 AC 72 ms
71,224 KB
testcase_26 AC 75 ms
71,304 KB
testcase_27 AC 70 ms
71,552 KB
testcase_28 AC 73 ms
71,220 KB
testcase_29 AC 74 ms
71,328 KB
testcase_30 AC 72 ms
71,212 KB
testcase_31 AC 77 ms
71,324 KB
testcase_32 AC 73 ms
71,572 KB
testcase_33 AC 72 ms
71,240 KB
testcase_34 AC 76 ms
71,444 KB
testcase_35 AC 73 ms
71,328 KB
testcase_36 AC 71 ms
71,420 KB
testcase_37 AC 135 ms
78,616 KB
testcase_38 AC 140 ms
78,732 KB
testcase_39 AC 135 ms
78,608 KB
testcase_40 AC 134 ms
78,280 KB
testcase_41 AC 135 ms
78,532 KB
testcase_42 AC 140 ms
78,576 KB
testcase_43 AC 136 ms
77,680 KB
testcase_44 AC 138 ms
78,304 KB
testcase_45 WA -
testcase_46 AC 127 ms
77,336 KB
testcase_47 AC 121 ms
84,516 KB
testcase_48 AC 203 ms
113,536 KB
testcase_49 AC 137 ms
78,616 KB
testcase_50 WA -
testcase_51 AC 199 ms
113,620 KB
testcase_52 AC 198 ms
113,484 KB
testcase_53 AC 198 ms
113,680 KB
testcase_54 AC 201 ms
113,488 KB
testcase_55 AC 195 ms
113,616 KB
testcase_56 AC 198 ms
113,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


n,K = list(map(int, input().split()))
a = list(map(int, input().split()))
a0 = a[:n//2]
a1 = a[n//2:]
l0 = {}
l1 = {}
def sub(a):
    res = {}
    for b in range(pow(3,len(a))):
        val = 0
        p = m = 0
        for i in range(len(a)):
            if b%3==0:
                val += a[i]
                p += 1
            elif b%3==1:
                val -= a[i]
                m += 1
            b //= 3
        res.setdefault(val, set())
        vv = (p>0) | (2*(m>0))
        res[val].add(vv)
    return res
l0 = sub(a0)
l1 = sub(a1)
for k,v in l0.items():
    if K-k in l1:
        ss = v|l1[K-k]
        if 3 in ss or (1 in ss and 2 in ss):
            print("Yes")
            break
else:
    print("No")
0