結果

問題 No.1538 引きこもりさんは引き算が得意。
コンテスト
ユーザー norioc
提出日時 2024-02-08 03:05:11
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 675 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 317 ms
コンパイル使用メモリ 96,068 KB
実行使用メモリ 1,340,024 KB
最終ジャッジ日時 2026-09-05 16:12:10
合計ジャッジ時間 12,794 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40 WA * 4 MLE * 2 -- * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def subs(a: list) -> set:
    s = set()
    for x in a:
        t = s.copy()
        for y in s:
            t.add(x - y)
            t.add(y - x)
        t.add(x)
        s = t
    return s


N, K = map(int, input().split())
A = list(map(int, input().split()))

if K in A:
    print('Yes')
    exit()


def solve():
    a = A[:N//2]
    b = A[N//2:]

    xs = subs(a)
    ys = subs(b)
    print(f'{a=} {xs=}')
    print(f'{b=} {ys=}')
    if K in xs or K in ys: return True
    for x in xs:
        if x-K in ys or x+K in ys:
            return True
    return False


def solve2():
    xs = subs(A)
    return K in xs


if solve2():
    print('Yes')
else:
    print('No')
0