CF codeforces A. New Year Garland【Educational Codeforces Round 79 (Rated for Div. 2)】
A. New Year Garland
1 second
256 megabytes
standard input
standard output
Polycarp is sad — New Year is coming in few days but there is still no snow in his city. To bring himself New Year mood, he decided to decorate his house with some garlands.
The local store introduced a new service this year, called "Build your own garland". So you can buy some red, green and blue lamps, provide them and the store workers will solder a single garland of them. The resulting garland will have all the lamps you provided put in a line. Moreover, no pair of lamps of the same color will be adjacent to each other in this garland!
For example, if you provide 33 red, 33 green and 33 blue lamps, the resulting garland can look like this: "RGBRBGBGR" ("RGB" being the red, green and blue color, respectively). Note that it's ok to have lamps of the same color on the ends of the garland.
However, if you provide, say, 11 red, 1010 green and 22 blue lamps then the store workers won't be able to build any garland of them. Any garland consisting of these lamps will have at least one pair of lamps of the same color adjacent to each other. Note that the store workers should use all the lamps you provided.
So Polycarp has bought some sets of lamps and now he wants to know if the store workers can build a garland from each of them.
The first line contains a single integer tt (1≤t≤1001≤t≤100) — the number of sets of lamps Polycarp has bought.
Each of the next tt lines contains three integers rr, gg and bb (1≤r,g,b≤1091≤r,g,b≤109) — the number of red, green and blue lamps in the set, respectively.
Print tt lines — for each set of lamps print "Yes" if the store workers can build a garland from them and "No" otherwise.
3
3 3 3
1 10 2
2 1 1
Yes
No
Yes
The first two sets are desribed in the statement.
The third set produces garland "RBRG", for example.

既然首尾颜色可以相同,那怎么能叫花环呢
那应该就是一个链啊
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
BBBBBBBBBBBBBBBBBBBBBBBBBB
GGGGGGGGGGGGGGGGGGGGG
RBRBRBRBRBRBRBRBRBRBRBRBRBRBRBRBRRRRRRRRRRRRR;
RBRBRBRBRBRBRBRBRBRBRBRBRBRBRBRBRGRGRGRGRGRG
↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
简明扼要的表达了思路
【这题是大佬直接讲的他的思路】(白嫖思路)
思路如下:
首先先排序,先把最大的和第二大的插空(RBRBRBRBRBRBRBRRRRRRRRR)
这时候肯定多了一些最大的那个颜色,这时候就把最少的颜色拿来补
我们只要知道最少的颜色满足的某个区间,就可以快乐输出了、
a[0]>=abs(a[1]-a[2])-1且a[0]<=a[1]+a[2]+abs(a[1]-a[2])“a[0]表示最小的数”
不过a[0]>***的式子很多余。。。。。(不管了,我好不容易推出来的式子我就要加上)
#include <bits/stdc++.h> using namespace std; int main()
{
long long a[];
int t;
cin>>t;
while(t--){
cin>>a[]>>a[]>>a[];
sort(a,a+);
if(a[]>=abs(a[]-a[])-&&a[]<=a[]+a[]+abs(a[]-a[]))
14 cout<<"yes"<<'\n';
else cout<<"no"<<'\n';
}
return ;
}
CF codeforces A. New Year Garland【Educational Codeforces Round 79 (Rated for Div. 2)】的更多相关文章
- 【Educational Codeforces Round 38 (Rated for Div. 2)】 Problem A-D 题解
[比赛链接] 点击打开链接 [题解] Problem A Word Correction[字符串] 不用多说了吧,字符串的基本操作 Problem B Run for your prize[贪心] ...
- 【Educational Codeforces Round 53 (Rated for Div. 2)】
A:https://www.cnblogs.com/myx12345/p/9853775.html B:https://www.cnblogs.com/myx12345/p/9853779.html ...
- 【Educational Codeforces Round 49 (Rated for Div. 2) 】
A:https://www.cnblogs.com/myx12345/p/9843826.html B:https://www.cnblogs.com/myx12345/p/9843869.html ...
- Educational Codeforces Round 79 (Rated for Div. 2) Finished (A-D)
如果最大值比剩余两个加起来的总和+1还大,就是NO,否则是YES #include<bits/stdc++.h> using namespace std; int main(){ int ...
- Educational Codeforces Round 79 (Rated for Div. 2) - D. Santa's Bot(数论)
题意:有$n$个孩子,第$i$个孩子有$k[i]$件想要的礼物,第$j$个礼物为$a[i][j]$,现在随机挑一个孩子,从他想要的礼物里面随机挑一个,然后送给另一个孩子$($这个孩子可以和第一个孩子是 ...
- Educational Codeforces Round 65 (Rated for Div. 2)题解
Educational Codeforces Round 65 (Rated for Div. 2)题解 题目链接 A. Telephone Number 水题,代码如下: Code #include ...
- Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块
Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块 [Problem Description] ...
- Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题
Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题 [Problem Description] 总共两次询 ...
- Educational Codeforces Round 72 (Rated for Div. 2)-D. Coloring Edges-拓扑排序
Educational Codeforces Round 72 (Rated for Div. 2)-D. Coloring Edges-拓扑排序 [Problem Description] 给你 ...
随机推荐
- 不同浏览器Cookie大小
一.浏览器允许每个域名所包含的 cookie 数:Microsoft 指出 Internet Explorer 8 增加 cookie 限制为每个域名 50 个,但 IE7 似乎也允许每个域名 50 ...
- IP 转发分组的流程
IP 转发分组的流程 数据路由:路由器在不同网段转发数据包: 网络畅通的条件:数据包能去能回: 从源网络发出时,沿途的每一个路由器必须知道到目标网络下一跳给哪个接口: 从目标网络返回时,沿途的每一个路 ...
- USB小白学习之路(5) HID鼠标程序
HID鼠标程序 1. 特别注意 需要特别注意,各个例程中的设备描述符,配置描述符等各种描述符都是已经配置好了的,我们需要做的只是在例程中将代码修改为自己需要的部分即可,一般情况下是不可以串搭配的. 2 ...
- 跟我猜Spring-Boot:bean的创建
废话在前 最近几年的技术路子很杂,先是node,然后是php,后来是openresty,再后来转到了java,而接触的框架(Framework),也越发的复杂,从最开始的express/koa,到lu ...
- py装饰器,生成器,迭代器
emmmmm....看了好久才能大概的看懂一点关于装饰器的内容...import sys # 引入sys模块import timeimport functoolsfrom functools impo ...
- Failed to open the key database file. c;\\User\\w\\Destop\\SecureCRT_FX6.5.3\\Config\\KnowHosts\\Hostsmap.txt这个问题的解决方法
1.首先将这段错误在百度翻译上面查询一下,是什么意思,查询结果如下: 打开密钥数据库文件失败.C:\用户\ w \平台\ securecrt_fx6.5.3 \\ \\ \\ hostsmap.txt ...
- 使用QT绘制一个多边形
目录 1. 概述 2. 实现 2.1. 代码 2.2. 解析 3. 结果 1. 概述 可以通过QT的重绘事件和鼠标事件来绘制多边形,最简单的办法就是在继承QWidget的窗体中重写paintEvent ...
- htmlhint 规则详解
HTML 静态检查规则 HTMLHint 工具内置 23 条规则,可以对 HTML 代码文件进行静态代码检查,从而提高 HTML 代码编写的规范和质量.现在把 23 条规则翻译如下. 一.规则列表 标 ...
- Flutter 拖拽排序组件 ReorderableListView
注意:无特殊说明,Flutter版本及Dart版本如下: Flutter版本: 1.12.13+hotfix.5 Dart版本: 2.7.0 ReorderableListView是通过长按拖动某一项 ...
- python装饰器之函数作用域
1.函数作用域LEGB L:local函数内部作用域 E:enclosing函数内部与内嵌函数之间 G:global全局作用域 B:build-in内置作用域 passline = 60 def fu ...