B. Japanese Crosswords Strike Back
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

A one-dimensional Japanese crossword can be represented as a binary string of length x. An encoding of this crossword is an array a of size n, where n is the number of segments formed completely of 1's, and ai is the length of i-th segment. No two segments touch or intersect.

For example:

  • If x = 6 and the crossword is 111011, then its encoding is an array {3, 2};
  • If x = 8 and the crossword is 01101010, then its encoding is an array {2, 1, 1};
  • If x = 5 and the crossword is 11111, then its encoding is an array {5};
  • If x = 5 and the crossword is 00000, 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!

Input

The first line contains two integer numbers n and x (1 ≤ n ≤ 100000, 1 ≤ x ≤ 109) — the number of elements in the encoding and the length of the crossword Mishka picked.

The second line contains n integer numbers a1, a2, ..., an (1 ≤ ai ≤ 10000) — the encoding.

Output

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

Examples
input
2 4
1 3
output
NO
input
3 10
3 3 2
output
YES
input
2 10
1 3
output
NO
【题意】:给了段数和长度,以及每一段的长度,问是否只有唯一一种情况,只要满足a1+a2+...+an=x-n+1即可
【分析】:rt
【代码】:
#include <bits/stdc++.h>

using namespace std;
#define inf 1e18+100
#define LL long long const int maxn = 1e5+; int main()
{
int n,m,sum;
int a[maxn];
while(cin>>n>>m)
{
sum=;
for(int i=;i<n;i++)
{
cin>>a[i];
sum+=a[i];
}
if(sum==m-n+)
puts("YES");
else
puts("NO");
}
}

最新文章

  1. Spring MVC中的ModelMap作用及用法
  2. pywin32 创建一个窗口
  3. 如何修改WAMP中mysql默认空密码
  4. js隐藏或显示某区域
  5. kafka命令
  6. C++中 :: 的意思
  7. LightOJ 1079 Just another Robbery 概率背包
  8. JLINK使用教程详解,以及与JTAG区别
  9. SQL事物用法【转】
  10. js中eval函数
  11. apache启动报错:the requested operation has failed解决办法
  12. 阻塞IO
  13. pstree:command not found
  14. cookie跟session自我介绍
  15. day27、28 二十八、项目:选课系统
  16. 简单比较init-method,afterPropertiesSet和BeanPostProcessor
  17. web.xml 文件头
  18. atom插件安装失败解决方法
  19. EF select 匿名类 问题
  20. Kibana中的Coordinate Map地图报索引错误的问题

热门文章

  1. 如何在 Eclipse 中使用插件构建 PHP 开发环境[转]
  2. 24、php知识点总结基础教程--part-2
  3. flask-ssti,xss的防止
  4. ASP NET Core ---FluentValidation
  5. 过滤器(Filter)和Nuget
  6. Java UDP的简单实例以及知识点简述
  7. Java 多线程(Thread)学习
  8. jQuery静态分页功能
  9. JNDI连接数据库的详细步骤 以及简要的c3po数据库连接的配置
  10. hihocoder 1457 后缀自动机四&#183;重复旋律7 求不同子串的和