Pillow Stacking

시간 제한3초메모리 제한1024 MB

요약
여러 종류의 베개를 원하는 만큼 쌓아 목표 부드러움 C를 정확히 만들 수 있는지 판정한다. i번째 베개의 기여는 2^(i-1)로 나눈 값의 올림이다.
난이도

보통10점 중 7점

유형
동적 계획법, 그리디, 수학
정답자
아직 제출이 없습니다

문제

Eleanor has recently lost her favorite pillow. Being very particular about her pillows, she categorizes pillows by their softness. The pillow she lost had softness CC, and she will be unable to sleep without this exact softness. While she has access to some other types of pillows, there may not be any of her desired softness. As a work-around, she is willing to sleep with multiple pillows in a stack. When pillows with softness C_1,C_2,…,C_kC\_1, C\_2, \ldots, C\_k are stacked together in that order, the resulting softness is equal to \[ C_1 + \left\lceil \frac{C_2}{2} \right\rceil + \left\lceil \frac{C_3}{4} \right\rceil + \ldots + \left\lceil \frac{C_k}{2^{k-1}} \right\rceil. \] In other words, the iith pillow in the stack contributes 2−(i−1)2^{-(i-1)} of its softness, rounded up. Note that ⌈f⌉\lceil f \rceil is defined as the smallest integer xx with x≥fx \geq f.

Eleanor has a lot of money and is willing to use an unlimited amount of each pillow type she has access to. Can you help her determine if there is a way to stack pillows to reach her desired softness?

입력

The first line of input contains two integers NN and CC (1≤N≤1031 \leq N \leq 10^3 and 1≤C≤1041 \leq C \leq 10^4). NN indicates the number of types of pillows Eleanor has access to, and CC indicates the desired softness level. The next line contains NN integers a_1,a_2,…,a_Na\_1, a\_2, \ldots, a\_N (1≤a_i≤10181 \leq a\_i \leq 10^{18}), indicating the softness of pillows that Eleanor has access to.

출력

If it is possible for Eleanor to stack pillows to reach softness CC, output YES. Otherwise, output NO.

예제3

  1. 예제 1

    입력
    1 1000
    1
    
    예상 출력
    YES
    
  2. 예제 2

    입력
    1 5
    4
    
    예상 출력
    NO
    
  3. 예제 3

    입력
    2 100
    51 98
    
    예상 출력
    YES