CF884B.Japanese Crosswords Strike Back

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A one-dimensional Japanese crossword can be represented as a binary string of length xx . An encoding of this crossword is an array aa of size nn , where nn is the number of segments formed completely of 11 's, and aia_{i} is the length of ii -th segment. No two segments touch or intersect.

For example:

  • If x=6x=6 and the crossword is 111011111011 , then its encoding is an array 3,2{3,2} ;
  • If x=8x=8 and the crossword is 0110101001101010 , then its encoding is an array 2,1,1{2,1,1} ;
  • If x=5x=5 and the crossword is 1111111111 , then its encoding is an array 5{5} ;
  • If x=5x=5 and the crossword is 0000000000 , then its encoding is an empty array.

Mishka wants to create a new one-dimensional Japanese crossword. He has already picked the length and the encoding for this crossword. And now he needs to check if there is exactly one crossword such that its length and encoding are equal to the length and encoding he picked. Help him to check it!

输入格式

The first line contains two integer numbers nn and xx ( 1<=n<=1000001<=n<=100000 , 1<=x<=1091<=x<=10^{9} ) — the number of elements in the encoding and the length of the crossword Mishka picked.

The second line contains nn integer numbers a1a_{1} , a2a_{2} , ..., ana_{n} ( 1<=ai<=100001<=a_{i}<=10000 ) — the encoding.

输出格式

Print YES if there exists exaclty one crossword with chosen length and encoding. Otherwise, print NO.

输入输出样例

  • 输入#1

    2 4
    1 3
    

    输出#1

    NO
    
  • 输入#2

    3 10
    3 3 2
    

    输出#2

    YES
    
  • 输入#3

    2 10
    1 3
    

    输出#3

    NO
    
首页