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],让 ...
随机推荐
- shell判断文件是否存在[转]
原文出处: http://canofy.iteye.com/blog/252289 shell判断文件,目录是否存在或者具有权限 #!/bin/sh myPath="/var/log/htt ...
- jQuery监控动画执行完毕事件
$('#yourElement').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend' ...
- Pascal小游戏 随机函数
一个被人写滥了的小程序,新手学习,Pascal By Chaobs 初学者可以用它来学习随机函数的运用,当然你完全可以自己写一个随机函数. var player1,player2:longint; ...
- thinkPHP 表单自动验证功能
昨天晚上我们老大叫我弄表单自动验证功能,愁了半天借鉴了好多官网的知识,才出来,诶,总之分享一下我自己的成果吧! thinkphp 在Model基类为我们定义了自动验证的函数和正则表达式,我们只需要在对 ...
- Percona-Tookit工具包之pt-slave-restart
Preface Sometimes,the threads(especially the SQL_Thread) will be terminated by accident.The ...
- CentOS 7.5 部署蓝鲸运维平台
环境准备 官方建议 准备至少3台 CentOS 7 以上操作系统的机器 最低配置:2核4G 建议配置: 4核12G 以上 部署前关闭待安装主机之间防火墙,保证蓝鲸主机之间通信无碍 部署前关闭SELin ...
- table内容超出宽度时隐藏并显示省略标记
HTML中,一个表格,要达到二个条件: 1.内容多了不自动换行: 2.固定单元格宽度.如果内容超出,则隐藏: 如 果在IE下,只是写成<table style="table-layou ...
- iOS如何隐藏状态栏,包括网络标志、时间标志、电池标志等
我们在开发App的时候,在遇到有状态栏时,NavigationBar上面的按钮,是极难点击的,所以这个时候,最好我们能够人为的隐藏掉状态栏. 如果一直需要隐藏的话,直接在info.plist里面,添加 ...
- CodeForces Round #515 Div.3 A. Vova and Train
http://codeforces.com/contest/1066/problem/A Vova plans to go to the conference by train. Initially, ...
- 【bzoj4894】天赋 矩阵树定理
题目描述 小明有许多潜在的天赋,他希望学习这些天赋来变得更强.正如许多游戏中一样,小明也有n种潜在的天赋,但有一些天赋必须是要有前置天赋才能够学习得到的.也就是说,有一些天赋必须是要在学习了另一个天赋 ...