結果

問題 No.1538 引きこもりさんは引き算が得意。
ユーザー ygd.ygd.
提出日時 2021-06-12 22:37:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 281 ms / 2,000 ms
コード長 1,618 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 87,252 KB
実行使用メモリ 110,304 KB
最終ジャッジ日時 2023-08-22 19:29:03
合計ジャッジ時間 10,652 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,872 KB
testcase_01 AC 92 ms
71,352 KB
testcase_02 AC 97 ms
71,708 KB
testcase_03 AC 99 ms
71,904 KB
testcase_04 AC 94 ms
71,796 KB
testcase_05 AC 94 ms
71,752 KB
testcase_06 AC 95 ms
71,644 KB
testcase_07 AC 94 ms
71,828 KB
testcase_08 AC 94 ms
71,732 KB
testcase_09 AC 94 ms
71,744 KB
testcase_10 AC 96 ms
71,672 KB
testcase_11 AC 95 ms
71,400 KB
testcase_12 AC 95 ms
71,436 KB
testcase_13 AC 94 ms
71,404 KB
testcase_14 AC 101 ms
77,556 KB
testcase_15 AC 95 ms
71,772 KB
testcase_16 AC 95 ms
71,384 KB
testcase_17 AC 96 ms
71,716 KB
testcase_18 AC 97 ms
71,688 KB
testcase_19 AC 96 ms
71,400 KB
testcase_20 AC 95 ms
71,776 KB
testcase_21 AC 95 ms
71,664 KB
testcase_22 AC 95 ms
71,656 KB
testcase_23 AC 94 ms
71,376 KB
testcase_24 AC 95 ms
71,876 KB
testcase_25 AC 94 ms
71,820 KB
testcase_26 AC 95 ms
71,728 KB
testcase_27 AC 96 ms
71,700 KB
testcase_28 AC 94 ms
71,588 KB
testcase_29 AC 93 ms
71,704 KB
testcase_30 AC 93 ms
71,708 KB
testcase_31 AC 94 ms
71,432 KB
testcase_32 AC 94 ms
71,800 KB
testcase_33 AC 93 ms
71,692 KB
testcase_34 AC 93 ms
71,732 KB
testcase_35 AC 95 ms
71,816 KB
testcase_36 AC 95 ms
71,548 KB
testcase_37 AC 231 ms
82,924 KB
testcase_38 AC 233 ms
83,012 KB
testcase_39 AC 236 ms
83,480 KB
testcase_40 AC 231 ms
81,848 KB
testcase_41 AC 224 ms
81,852 KB
testcase_42 AC 232 ms
83,060 KB
testcase_43 AC 95 ms
71,828 KB
testcase_44 AC 136 ms
78,944 KB
testcase_45 AC 233 ms
83,012 KB
testcase_46 AC 226 ms
82,284 KB
testcase_47 AC 180 ms
84,924 KB
testcase_48 AC 265 ms
102,092 KB
testcase_49 AC 191 ms
80,792 KB
testcase_50 AC 93 ms
71,608 KB
testcase_51 AC 279 ms
110,304 KB
testcase_52 AC 275 ms
106,184 KB
testcase_53 AC 271 ms
104,600 KB
testcase_54 AC 276 ms
110,304 KB
testcase_55 AC 270 ms
104,772 KB
testcase_56 AC 281 ms
110,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict 

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    if K in A: print("Yes");exit()
    s = set([])
    B = A[:N//2]
    C = A[N//2:]
    c = [-1,0,1]
    S = defaultdict(list)
    for i in range(3**len(B)):
        cmx = 0; cmn = 0
        val = 0
        for j in range(len(B)):
            sig = i%(3**(j+1))
            sig //= 3**j
            #print(i,j,sig)
            if sig == 0: #-1
                val -= B[j]
                cmn = min(cmn, -1)
            elif sig == 2: #+1
                val += B[j]
                cmx = max(cmx, 1)
        #print("VAL",val,cmx,cmn)
        if cmx == 1 and cmn == -1 and val == K:
            print("Yes");exit()
        S[val].append((cmx,cmn))
    #print(S)

    T = defaultdict(list)
    for i in range(3**len(C)):
        cmx = 0; cmn = 0
        val = 0
        for j in range(len(C)):
            sig = i%(3**(j+1))
            sig //= 3**j
            #print(i,j,sig)
            if sig == 0: #-1
                val -= C[j]
                cmn = min(cmn, -1)
            elif sig == 2: #+1
                val += C[j]
                cmx = max(cmx, 1)
        #print("VAL",val,cmx,cmn)
        if cmx == 1 and cmn == -1 and val == K:
            print("Yes");exit()
        T[val].append((cmx,cmn))
    #print(T)

    for x in S:
        nokori = K - x
        for xmx, xmn in S[x]:
            for ymx,ymn in T[nokori]:
                if max(xmx,ymx) == 1 and min(xmn,ymn) == -1:
                    print("Yes");exit()
    
    print("No")




if __name__ == '__main__':
    main()
0