Under construction

Still being built. Things may change

Pillow Stacking

Time limit3sMemory limit1024 MB

Summary
Given N pillow softness values and a target C, decide whether a stack of pillows (none with softness C) can reach total softness C.
Level

Medium6 of 10

Topics
Dynamic programming, Math
Solved
No attempts yet

Problem

Eleanor recently lost her favorite pillow. She is very particular about her pillows and sorts them by softness. The pillow she lost had softness CC, and she cannot sleep without this exact softness. She has access to several other types of pillows, but none of them may have softness CC. To work around this, she sleeps on a stack of multiple pillows.

When pillows with softness C1,C2,…,CkC_1, C_2, \ldots, C_k are stacked in that order, the resulting softness is

C1+⌈C22⌉+⌈C34⌉+⋯+⌈Ck2k−1⌉C_1 + \left\lceil \frac{C_2}{2} \right\rceil + \left\lceil \frac{C_3}{4} \right\rceil + \cdots + \left\lceil \frac{C_k}{2^{k-1}} \right\rceil

In other words, the iith pillow contributes 2−(i−1)2^{-(i-1)} of its softness, rounded up. ⌈f⌉\lceil f \rceil is the smallest integer xx with x≥fx \geq f.

Eleanor has plenty of money and can use an unlimited number of each pillow type she has access to. Determine whether she can stack pillows to reach softness CC.

Input

The first line contains two integers NN and CC (1≤N≤1031 \leq N \leq 10^3, 1≤C≤1041 \leq C \leq 10^4). NN is the number of pillow types Eleanor has access to, and CC is the desired softness. The next line contains NN integers a1,a2,…,aNa_1, a_2, \ldots, a_N (1≤ai≤10181 \leq a_i \leq 10^{18}), the softness of each pillow type.

Output

If Eleanor can stack pillows to reach softness CC, print YES. Otherwise, print NO.

Examples3

  1. Example 1

    Input
    1 1000
    1
    
    Expected output
    YES
    
  2. Example 2

    Input
    1 5
    4
    
    Expected output
    NO
    
  3. Example 3

    Input
    2 100
    51 98
    
    Expected output
    YES