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");
}
}

Educational Codeforces Round 31 B. Japanese Crosswords Strike Back【暴力】的更多相关文章

  1. 【Educational Codeforces Round 31 B】Japanese Crosswords Strike Back

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 所有数字的和加上n-1,如果为x则唯一,否则不唯一 [代码] #include <bits/stdc++.h> usin ...

  2. Educational Codeforces Round 31 A. Book Reading【暴力】

    A. Book Reading time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  3. Educational Codeforces Round 31

    A. Book Reading time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  4. 【Educational Codeforces Round 31 C】Bertown Subway

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 最后肯定会形成若干个环的. 把最大的两个环合在一起就好. 每个环贡献: 假设x=环的大小 ->x*x 注意int的溢出 [代码 ...

  5. 【Educational Codeforces Round 31 A】Book Reading

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 水模拟 [代码] #include <bits/stdc++.h> using namespace std; const ...

  6. Educational Codeforces Round 4 B. HDD is Outdated Technology 暴力

    B. HDD is Outdated Technology 题目连接: http://www.codeforces.com/contest/612/problem/B Description HDD ...

  7. Educational Codeforces Round 1 B. Queries on a String 暴力

    B. Queries on a String Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/59 ...

  8. Educational Codeforces Round 24 A 水 B stl C 暴力 D stl模拟 E 二分

    A. Diplomas and Certificates time limit per test 1 second memory limit per test 256 megabytes input ...

  9. Educational Codeforces Round 22 B. The Golden Age(暴力)

    题目链接:http://codeforces.com/contest/813/problem/B 题意:就是有一个数叫做不幸运数,满足题目的 n = x^a + y^b,现在给你一个区间[l,r],让 ...

随机推荐

  1. mongodb导入json文件(WINDOWS)

    mongodb导入json格式的文件的命令是mongoimport: 在下面的这个例子中,使用mongoimport命令将文件pi.json中的内容导入loacal数据库的pi集合中. 打开CMD,进 ...

  2. ASP.NET Core 认证与授权[1]:初识认证 (笔记)

    原文链接:  https://www.cnblogs.com/RainingNight/p/introduce-basic-authentication-in-asp-net-core.html 在A ...

  3. Spring 学习笔记(五)—— Bean之间的关系、作用域、自动装配

    继承 Spring提供了配置信息的继承机制,可以通过为<bean>元素指定parent值重用已有的<bean>元素的配置信息. <?xml version="1 ...

  4. 那些牛掰的 HTML5的API(二)

    1:视频播放器 2:地理定位 我们的支持html5 的浏览器给我们提供一个接口(api),可以用来获取你当前的位置. 主要是通过geolocation(地理位置),对象 ,去访问硬件,来获取到经纬度. ...

  5. poj1936 假期计划第一水

    All in All Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 29651   Accepted: 12312 Desc ...

  6. 【转】Thinkphp框架的项目规划总结和踩坑经验

    http://www.360doc.com/content/16/1206/22/466494_612576533.shtml

  7. npm & npm config

    npm command show npm config https://docs.npmjs.com/cli/config https://docs.npmjs.com/cli/ls https:// ...

  8. Python中的多线程编程,线程安全与锁(一)

    1. 多线程编程与线程安全相关重要概念 在我的上篇博文 聊聊Python中的GIL 中,我们熟悉了几个特别重要的概念:GIL,线程,进程, 线程安全,原子操作. 以下是简单回顾,详细介绍请直接看聊聊P ...

  9. Scala 基础(7)—— 函数字面量和一等函数

    1. 函数字面量 在 Scala 基础(3)—— 基础类型和基础操作 中提到了函数字面量,这里具体解释函数字面量的语法. 下面展示一个具体的函数字面量,它由三部分组成: (x: Int, y: Int ...

  10. Linux系统——提高编译速度的方法

    编译优化: 基本原则就是“以空间换时间” tmpfs: 解决IO瓶颈,充分利用本机内存资源 make -j: 充分利用本机计算资源 distcc: 利用多台计算机资源 ccache: 减少重复编译相同 ...