結果

問題 No.1538 引きこもりさんは引き算が得意。
ユーザー vwxyzvwxyz
提出日時 2023-11-30 20:19:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 251 ms / 2,000 ms
コード長 1,536 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 96,724 KB
最終ジャッジ日時 2023-11-30 20:19:47
合計ジャッジ時間 11,710 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
88,800 KB
testcase_01 AC 151 ms
88,800 KB
testcase_02 AC 146 ms
88,800 KB
testcase_03 AC 172 ms
88,800 KB
testcase_04 AC 139 ms
88,800 KB
testcase_05 AC 137 ms
88,800 KB
testcase_06 AC 140 ms
88,800 KB
testcase_07 AC 140 ms
88,800 KB
testcase_08 AC 139 ms
88,800 KB
testcase_09 AC 142 ms
88,800 KB
testcase_10 AC 141 ms
88,800 KB
testcase_11 AC 150 ms
88,800 KB
testcase_12 AC 138 ms
88,800 KB
testcase_13 AC 137 ms
88,800 KB
testcase_14 AC 145 ms
89,952 KB
testcase_15 AC 138 ms
88,800 KB
testcase_16 AC 137 ms
88,800 KB
testcase_17 AC 138 ms
88,800 KB
testcase_18 AC 139 ms
88,800 KB
testcase_19 AC 137 ms
88,800 KB
testcase_20 AC 148 ms
88,800 KB
testcase_21 AC 139 ms
88,800 KB
testcase_22 AC 140 ms
88,800 KB
testcase_23 AC 138 ms
88,800 KB
testcase_24 AC 150 ms
88,800 KB
testcase_25 AC 146 ms
88,800 KB
testcase_26 AC 148 ms
88,800 KB
testcase_27 AC 140 ms
88,800 KB
testcase_28 AC 140 ms
88,800 KB
testcase_29 AC 140 ms
88,800 KB
testcase_30 AC 139 ms
88,800 KB
testcase_31 AC 149 ms
88,800 KB
testcase_32 AC 146 ms
88,800 KB
testcase_33 AC 141 ms
88,800 KB
testcase_34 AC 145 ms
88,800 KB
testcase_35 AC 146 ms
88,800 KB
testcase_36 AC 150 ms
88,800 KB
testcase_37 AC 205 ms
90,208 KB
testcase_38 AC 206 ms
90,336 KB
testcase_39 AC 203 ms
90,208 KB
testcase_40 AC 227 ms
90,336 KB
testcase_41 AC 203 ms
90,208 KB
testcase_42 AC 205 ms
90,208 KB
testcase_43 AC 140 ms
88,800 KB
testcase_44 AC 244 ms
90,336 KB
testcase_45 AC 205 ms
90,208 KB
testcase_46 AC 227 ms
90,208 KB
testcase_47 AC 199 ms
92,384 KB
testcase_48 AC 251 ms
96,596 KB
testcase_49 AC 214 ms
90,464 KB
testcase_50 AC 150 ms
88,800 KB
testcase_51 AC 226 ms
96,724 KB
testcase_52 AC 230 ms
96,588 KB
testcase_53 AC 231 ms
96,592 KB
testcase_54 AC 221 ms
96,720 KB
testcase_55 AC 228 ms
96,592 KB
testcase_56 AC 216 ms
96,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import random
import sys
import time
from collections import Counter,deque,defaultdict
from functools import lru_cache,reduce
from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max
def _heappush_max(heap,item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappushpop_max(heap, item):
    if heap and item < heap[0]:
        item, heap[0] = heap[0], item
        heapq._siftup_max(heap, 0)
    return item
from math import gcd as GCD
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines
write=sys.stdout.write
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')
#sys.set_int_max_str_digits(10**9)

N,K=map(int,readline().split())
A=list(map(int,readline().split()))
ans="No"
if K in A:
    ans="Yes"
else:
    n=N//2
    se=set()
    for tpl in itertools.product((-1,0,1),repeat=n):
        bit0=0
        s0=0
        for a,i in zip(A[:n],tpl):
            if i==-1:
                bit0|=1
            elif i==1:
                bit0|=2
            s0+=a*i
        se.add((s0,bit0))
    for tpl in itertools.product((-1,0,1),repeat=N-n):
        bit1=0
        s1=0
        for a,i in zip(A[n:],tpl):
            if i==-1:
                bit1|=1
            elif i==1:
                bit1|=2
            s1+=a*i
        s0=K-s1
        for bit0 in range(4):
            if bit0|bit1==3 and (s0,bit0) in se:
                ans="Yes"
print(ans)
0