結果

問題 No.1538 引きこもりさんは引き算が得意。
ユーザー AEnAEn
提出日時 2022-11-20 17:02:03
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 1,081 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 81,636 KB
実行使用メモリ 85,600 KB
最終ジャッジ日時 2023-10-21 14:56:14
合計ジャッジ時間 5,655 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
55,500 KB
testcase_01 AC 34 ms
55,500 KB
testcase_02 AC 35 ms
55,500 KB
testcase_03 AC 34 ms
55,500 KB
testcase_04 AC 33 ms
55,500 KB
testcase_05 AC 34 ms
55,500 KB
testcase_06 AC 34 ms
55,500 KB
testcase_07 AC 34 ms
55,500 KB
testcase_08 AC 34 ms
55,500 KB
testcase_09 AC 35 ms
55,500 KB
testcase_10 AC 35 ms
55,500 KB
testcase_11 WA -
testcase_12 AC 34 ms
55,500 KB
testcase_13 AC 33 ms
55,500 KB
testcase_14 AC 38 ms
61,836 KB
testcase_15 AC 32 ms
55,500 KB
testcase_16 AC 33 ms
55,500 KB
testcase_17 AC 34 ms
55,500 KB
testcase_18 AC 33 ms
55,500 KB
testcase_19 AC 33 ms
55,500 KB
testcase_20 AC 33 ms
55,500 KB
testcase_21 AC 33 ms
55,500 KB
testcase_22 AC 33 ms
55,500 KB
testcase_23 AC 33 ms
55,500 KB
testcase_24 AC 34 ms
55,500 KB
testcase_25 AC 34 ms
55,500 KB
testcase_26 AC 34 ms
55,500 KB
testcase_27 AC 34 ms
55,500 KB
testcase_28 AC 34 ms
55,500 KB
testcase_29 AC 34 ms
55,500 KB
testcase_30 AC 34 ms
55,500 KB
testcase_31 AC 34 ms
55,500 KB
testcase_32 AC 34 ms
55,500 KB
testcase_33 AC 34 ms
55,500 KB
testcase_34 AC 34 ms
55,500 KB
testcase_35 AC 33 ms
55,500 KB
testcase_36 AC 32 ms
55,500 KB
testcase_37 AC 72 ms
75,888 KB
testcase_38 AC 76 ms
75,884 KB
testcase_39 AC 80 ms
75,916 KB
testcase_40 AC 72 ms
75,748 KB
testcase_41 AC 72 ms
75,748 KB
testcase_42 AC 73 ms
75,884 KB
testcase_43 AC 72 ms
75,712 KB
testcase_44 WA -
testcase_45 AC 74 ms
75,888 KB
testcase_46 AC 70 ms
75,696 KB
testcase_47 AC 66 ms
77,920 KB
testcase_48 AC 91 ms
85,600 KB
testcase_49 WA -
testcase_50 WA -
testcase_51 AC 91 ms
85,600 KB
testcase_52 AC 89 ms
85,600 KB
testcase_53 AC 85 ms
85,600 KB
testcase_54 AC 92 ms
85,596 KB
testcase_55 AC 86 ms
85,600 KB
testcase_56 AC 90 ms
85,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
N, K = map(int, input().split())
A = list(map(int, input().split()))

p, q = A[:N//2],A[N//2:]
P = [set() for _ in range(3)]
Q = [set() for _ in range(3)]

def cal(p, P):
    for i in range(1,1<<len(p)):
        s = []
        for j in range(len(p)):
            if i&(1<<j):
                s.append(p[j])
        for j in range(1<<len(s)):
            sm = 0
            cp, cn = 0,0
            for k in range(len(s)):
                if j&(1<<k):
                    cp += 1
                    sm += s[k]
                else:
                    cn += 1
                    sm -= s[k]
            if cp>=1 and cn>=1:
                P[0].add(sm)
            elif cp>=1:
                P[1].add(sm)
            else:
                P[2].add(sm)

cal(p,P)
cal(q,Q)
for n1 in P[0]:
    for i in range(3):
        if K-n1 in Q[i]:
            exit(print('Yes'))
for n1 in P[1]:
    if (K-n1 in Q[0]) or (K-n1 in Q[2]):
        exit(print('Yes'))
for n1 in P[2]:
    if (K-n1 in Q[0]) or (K-n1 in Q[1]):
        exit(print('Yes'))
print('No')
0