Educational Codeforces Round 31 B. Japanese Crosswords Strike Back【暴力】
1 second
256 megabytes
standard input
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!
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.
Print YES if there exists exaclty one crossword with chosen length and encoding. Otherwise, print NO.
2 4
1 3
NO
3 10
3 3 2
YES
2 10
1 3
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【暴力】的更多相关文章
- 【Educational Codeforces Round 31 B】Japanese Crosswords Strike Back
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 所有数字的和加上n-1,如果为x则唯一,否则不唯一 [代码] #include <bits/stdc++.h> usin ...
- 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 ...
- Educational Codeforces Round 31
A. Book Reading time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- 【Educational Codeforces Round 31 C】Bertown Subway
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 最后肯定会形成若干个环的. 把最大的两个环合在一起就好. 每个环贡献: 假设x=环的大小 ->x*x 注意int的溢出 [代码 ...
- 【Educational Codeforces Round 31 A】Book Reading
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 水模拟 [代码] #include <bits/stdc++.h> using namespace std; const ...
- Educational Codeforces Round 4 B. HDD is Outdated Technology 暴力
B. HDD is Outdated Technology 题目连接: http://www.codeforces.com/contest/612/problem/B Description HDD ...
- 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 ...
- 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 ...
- Educational Codeforces Round 22 B. The Golden Age(暴力)
题目链接:http://codeforces.com/contest/813/problem/B 题意:就是有一个数叫做不幸运数,满足题目的 n = x^a + y^b,现在给你一个区间[l,r],让 ...
随机推荐
- dynamic基元类型与隐式类型的局部变量var
dynamic代码示例 using System; using System.Collections.Generic; using System.Linq; using System.Text; na ...
- Python列表深浅复制详解
转自:https://www.cnblogs.com/blaomao/p/7239203.html 在文章<Python 数据类型>里边介绍了列表的用法,其中列表有个 copy() 方法, ...
- python练习题及实现--文件处理、date日期
练习题作者:Vamei 出处:http://www.cnblogs.com/vamei http://www.cnblogs.com/vamei/archive/2012/07/19/2600135. ...
- java 继承小结
[code=java] //多态的经典例子 //向上转型后,父类只能调用子类和父类的共同方法和的重写方法(方法名相同,参数也相同),不能调用重载方法(方法名相同,但参数不同) class A { pu ...
- Action参数和View、Json、重定向
一.Action 1.Action参数: 普通参数.Model类.FormCollection (1).普通参数 Index(string name,int age) 框架会自动把用户请求的Que ...
- (原)DirectX11 深度测试(有点另类)
(问到自己清楚就可) @Author: 白袍小道 @说明:转载随缘,评论随缘,询问建议看书和源码会得到更准确的答案 深度测试的来源.目的.做法 一.问题询问 我们带着一些问题去浏览一番 1.深度测试发 ...
- 【志银】nginx_php_mysql_phpMyAdmin配置(Windows)
✄更新中... 更新日期:2018.11.22 ★版本说明+快捷下载(官网) nginx nginx-1.14.1 http://nginx.org/download/nginx-1.14.1. ...
- winform 使用Anchor属性进行界面布局
每个控件的定位方法: 一.使用Anchor: Anchor分为Left.Top.Right.Bottom四个属性. 它们的含义如下: Top——表示控件中与父窗体(或父控件)相关的顶部应该保持固定. ...
- POJ 2891 Strange Way to Express Integers | exGcd解同余方程组
题面就是让你解同余方程组(模数不互质) 题解: 先考虑一下两个方程 x=r1 mod(m1) x=r2 mod (m2) 去掉mod x=r1+m1y1 ......1 x=r2+m2y2 . ...
- vue中动态循环model
vue动态循环model与angular有所不同,angular直接定义一个数组,然后传入循环列表的index即可. 而vue不仅需要定义一个数组,还需要通过接口读出循环的数组长度,然后在create ...