結果

問題 No.1538 引きこもりさんは引き算が得意。
ユーザー shotoyooshotoyoo
提出日時 2021-06-17 00:35:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 202 ms / 2,000 ms
コード長 1,029 bytes
コンパイル時間 1,224 ms
コンパイル使用メモリ 86,804 KB
実行使用メモリ 113,676 KB
最終ジャッジ日時 2023-08-30 05:52:30
合計ジャッジ時間 9,727 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,280 KB
testcase_01 AC 75 ms
71,156 KB
testcase_02 AC 75 ms
71,488 KB
testcase_03 AC 81 ms
71,180 KB
testcase_04 AC 76 ms
71,076 KB
testcase_05 AC 75 ms
71,392 KB
testcase_06 AC 74 ms
71,036 KB
testcase_07 AC 74 ms
71,552 KB
testcase_08 AC 75 ms
71,264 KB
testcase_09 AC 75 ms
71,448 KB
testcase_10 AC 77 ms
71,304 KB
testcase_11 AC 74 ms
71,480 KB
testcase_12 AC 72 ms
71,448 KB
testcase_13 AC 73 ms
71,276 KB
testcase_14 AC 80 ms
76,180 KB
testcase_15 AC 71 ms
71,624 KB
testcase_16 AC 74 ms
71,344 KB
testcase_17 AC 72 ms
71,224 KB
testcase_18 AC 72 ms
71,156 KB
testcase_19 AC 74 ms
71,160 KB
testcase_20 AC 73 ms
71,132 KB
testcase_21 AC 71 ms
71,364 KB
testcase_22 AC 75 ms
71,324 KB
testcase_23 AC 72 ms
71,308 KB
testcase_24 AC 75 ms
71,484 KB
testcase_25 AC 74 ms
71,320 KB
testcase_26 AC 72 ms
71,328 KB
testcase_27 AC 74 ms
71,520 KB
testcase_28 AC 73 ms
71,264 KB
testcase_29 AC 72 ms
71,284 KB
testcase_30 AC 73 ms
71,184 KB
testcase_31 AC 73 ms
71,404 KB
testcase_32 AC 73 ms
71,224 KB
testcase_33 AC 73 ms
71,264 KB
testcase_34 AC 74 ms
71,492 KB
testcase_35 AC 72 ms
71,344 KB
testcase_36 AC 74 ms
71,184 KB
testcase_37 AC 136 ms
78,508 KB
testcase_38 AC 136 ms
78,488 KB
testcase_39 AC 138 ms
78,472 KB
testcase_40 AC 135 ms
78,240 KB
testcase_41 AC 138 ms
78,544 KB
testcase_42 AC 138 ms
78,768 KB
testcase_43 AC 132 ms
77,816 KB
testcase_44 AC 138 ms
78,096 KB
testcase_45 AC 139 ms
78,740 KB
testcase_46 AC 129 ms
77,328 KB
testcase_47 AC 131 ms
84,636 KB
testcase_48 AC 199 ms
113,676 KB
testcase_49 AC 137 ms
78,660 KB
testcase_50 AC 137 ms
78,904 KB
testcase_51 AC 198 ms
113,576 KB
testcase_52 AC 199 ms
113,464 KB
testcase_53 AC 196 ms
113,308 KB
testcase_54 AC 196 ms
113,600 KB
testcase_55 AC 200 ms
113,624 KB
testcase_56 AC 202 ms
113,304 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 v and 2 in l1[K-k]) or (2 in v and 1 in l1[K-k]):
            print("Yes")
            break
else:
    if K in a:
        print("Yes")
    else:
        print("No")
0