結果

問題 No.1538 引きこもりさんは引き算が得意。
ユーザー 👑 rin204rin204
提出日時 2022-03-24 14:58:40
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 816 bytes
コンパイル時間 201 ms
コンパイル使用メモリ 82,816 KB
実行使用メモリ 93,056 KB
最終ジャッジ日時 2024-04-21 01:02:43
合計ジャッジ時間 4,553 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,480 KB
testcase_01 AC 39 ms
52,480 KB
testcase_02 AC 39 ms
52,096 KB
testcase_03 WA -
testcase_04 AC 38 ms
52,352 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 38 ms
52,480 KB
testcase_09 AC 38 ms
52,352 KB
testcase_10 AC 38 ms
51,840 KB
testcase_11 AC 39 ms
51,840 KB
testcase_12 AC 39 ms
52,096 KB
testcase_13 AC 39 ms
51,840 KB
testcase_14 AC 39 ms
52,352 KB
testcase_15 WA -
testcase_16 AC 38 ms
52,352 KB
testcase_17 AC 38 ms
52,096 KB
testcase_18 AC 38 ms
52,096 KB
testcase_19 AC 38 ms
51,840 KB
testcase_20 AC 39 ms
52,224 KB
testcase_21 AC 39 ms
52,224 KB
testcase_22 AC 39 ms
52,096 KB
testcase_23 AC 39 ms
52,352 KB
testcase_24 AC 39 ms
52,224 KB
testcase_25 AC 39 ms
52,064 KB
testcase_26 AC 38 ms
52,352 KB
testcase_27 AC 38 ms
52,736 KB
testcase_28 AC 39 ms
52,096 KB
testcase_29 AC 38 ms
52,736 KB
testcase_30 AC 39 ms
52,352 KB
testcase_31 AC 37 ms
52,352 KB
testcase_32 AC 38 ms
51,968 KB
testcase_33 AC 38 ms
52,096 KB
testcase_34 AC 39 ms
52,352 KB
testcase_35 AC 39 ms
52,340 KB
testcase_36 AC 38 ms
52,608 KB
testcase_37 AC 49 ms
62,080 KB
testcase_38 AC 50 ms
61,568 KB
testcase_39 AC 48 ms
61,824 KB
testcase_40 AC 45 ms
60,032 KB
testcase_41 AC 46 ms
60,160 KB
testcase_42 AC 48 ms
61,764 KB
testcase_43 AC 39 ms
51,968 KB
testcase_44 AC 45 ms
60,032 KB
testcase_45 AC 50 ms
61,952 KB
testcase_46 WA -
testcase_47 AC 53 ms
68,864 KB
testcase_48 AC 77 ms
90,708 KB
testcase_49 AC 45 ms
60,544 KB
testcase_50 AC 38 ms
52,224 KB
testcase_51 AC 84 ms
92,928 KB
testcase_52 AC 82 ms
92,416 KB
testcase_53 AC 83 ms
92,472 KB
testcase_54 AC 86 ms
92,800 KB
testcase_55 AC 82 ms
93,056 KB
testcase_56 AC 87 ms
92,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def yes():
    print("Yes")
    exit()
    
def no():
    print("No")
    exit()

n, k = map(int, input().split())
A = list(map(int, input().split()))
if k in A:
    yes()
L = A[:n // 2]
R = A[n // 2:]

def f(A):
    pm = set()
    p = set()
    for a in A:
        add = {a}
        for s in p:
            add.add(s + a)
        
        add2 = set()
        for s in p:
            add2.add(abs(s - a))
        for s in pm:
            add2.add(abs(s + a))
            add2.add(abs(s - a))
            
        p |= add
        pm |= add2
    return p, pm
        
p1, pm1 = f(L)
p2, pm2 = f(R)

if k in pm1 or k in pm2:
    yes()

if -k in pm1 or -k in pm2:
    yes()

se1 = p1 | pm1
se2 = p2 | pm2
    
for s in se1:
    for x in [s + k, s - k, -s + k, -s - k]:
        if x in se2:
            yes()
no()
    
0