CF1468N.Waste Sorting
入门
通过率:0%
时间限制:2.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The progress is not standing still in Berland. Recently all garbage containers in Bertown, the capital of Berland, were replaced by differentiated recycling bins, each accepting some category of waste. While this will definitely improve the ecological situation, for some citizens it's difficult to get used to the habit of sorting waste.
Monocarp is one of those citizens who tries to get used to waste sorting. Today he has to take out the trash from his house. There are three containers near the Monocarp's house, the first one accepts paper waste, the second one accepts plastic waste, and the third one — all other types of waste. It is possible to fit c1 items into the first container, c2 items into the second container and c3 items into the third container.
Monocarp has a lot of items to throw into containers. Some are made of paper, so Monocarp has to put them into the first container (he has a1 such items), some are made of plastic, so he has to put them into the second container (he has a2 such items), and some are neither paper nor plastic — so Monocarp has to put them into the third container (he has a3 such items).
Unfortunately, there are also two categories of items that Monocarp is unsure of: he has a4 items which are partially made of paper, so he will put each of these items either into the first container or into the third container. Similarly, he has a5 items partially made of plastic, so he has to put each of them either into the second container or into the third container. Obviously, this choice is made separately for each item — for example, Monocarp can throw several partially-plastic items into the second container, and all other partially-plastic items — into the third one.
Now Monocarp wonders: is it possible to put each item into some container so that the first container will hold no more than c1 items, the second one — no more than c2 items, and the third one — no more than c3 items?
伯兰德国的进步从未停歇。最近,伯兰德首都贝尔敦市的所有垃圾箱均被替换为分类回收箱,每种箱子仅接收某一类别的废弃物。尽管此举必将改善生态环境,但对部分市民而言,养成垃圾分类的习惯仍较为困难。
莫诺卡普正是那些努力适应垃圾分类的市民之一。今天,他需要将家中的垃圾运出。在他家附近有三个容器:第一个用于投放纸类废弃物,第二个用于投放塑料类废弃物,第三个则用于投放所有其他类型的废弃物。第一个容器最多可容纳 c1 件物品,第二个容器最多可容纳 c2 件物品,第三个容器最多可容纳 c3 件物品。
莫诺卡普有许多待投放的物品。其中一些是纸制品,因此他必须将其投入第一个容器(共 a1 件);另一些是塑料制品,因此他必须将其投入第二个容器(共 a2 件);还有一些既非纸制品也非塑料制品,因此他必须将其投入第三个容器(共 a3 件)。
不幸的是,还有两类物品令莫诺卡普感到难以抉择:他有 a4 件物品部分由纸制成,因此每件此类物品可选择投入第一个容器或第三个容器;类似地,他有 a5 件物品部分由塑料制成,因此每件此类物品可选择投入第二个容器或第三个容器。显然,对每件物品的选择是独立进行的——例如,莫诺卡普可将若干件部分含塑料的物品投入第二个容器,而将其余所有部分含塑料的物品投入第三个容器。
现在,莫诺卡普想知道:是否存在一种投放方案,使得每个物品均被投入某个容器,且第一个容器中物品总数不超过 c1 件,第二个容器中不超过 c2 件,第三个容器中不超过 c3 件?
输入格式
The first line contains one integer t (1≤t≤3⋅104) — the number of test cases.
Each test case consists of two lines. The first line of each test case contains three integers c1, c2, c3 (0≤c1,c2,c3≤108) — the capacities of the containers.
The second line of each test case contains five integers a1, a2, a3, a4, a5 (0≤ai≤108), where ai is the number of items of the i-th category Monocarp has to throw out (i=1 is paper waste, i=2 is plastic waste, i=3 is general waste, i=4 is partially-paper waste, i=5 is partially-plastic waste).
第一行包含一个整数 t(1≤t≤3⋅104),表示测试用例的数量。
每个测试用例由两行组成。每个测试用例的第一行包含三个整数 c1、c2、c3(0≤c1,c2,c3≤108),分别表示三个容器的容量。
每个测试用例的第二行包含五个整数 a1、a2、a3、a4、a5(0≤ai≤108),其中 ai 表示 Monocarp 需要丢弃的第 i 类物品的数量(i=1 表示纸类垃圾,i=2 表示塑料类垃圾,i=3 表示普通垃圾,i=4 表示部分含纸类垃圾,i=5 表示部分含塑料类垃圾)。
输出格式
For each test case, print either YES if it is possible to fit all items into containers, or NO otherwise. You may print each letter in any case (for example, YES, Yes, yes, yEs will all be recognized as positive answer).
对于每个测试用例,如果可以将所有物品装入容器中,则输出 YES;否则输出 NO。你可以以任意大小写形式输出每个字母(例如,YES、Yes、yes、yEs 均被视为肯定回答)。
输入输出样例
输入#1
7 1 2 3 1 2 3 0 0 2 2 3 1 2 3 1 0 2 2 3 1 2 3 0 1 1 2 5 1 2 3 1 1 0 0 0 0 0 0 0 0 0 0 4 1 0 0 0 0 13 37 42 0 0 0 40 47
输出#1
YES YES NO YES YES NO YES
说明/提示
Explanations for the example test cases:
- Monocarp can put 1 item of paper waste into the first container, 2 items of plastic waste into the second container, and 3 items of general waste into the third container;
- Monocarp can put 1 item of paper waste and 1 item of partially-paper waste into the first container, 2 items of plastic waste into the second container, and 3 items of general waste into the third container;
- there is no answer since either the second container should contain 3 items, or the third container should contain 4 items;
- Monocarp can put 1 item of paper waste into the first container, 2 items of plastic waste into the second container, and 3 items of general waste, 1 item of partially-paper waste and 1 item of partially-plastic waste into the third container;
- there is no waste at all, so all containers can be left empty;
- there's no answer since it's impossible to put a paper item into the third container;
- Monocarp can put 10 items of partially-paper waste into the first container, 37 items of partially-plastic waste into the second container, and 30 items of partially-paper waste and 10 items of partially-plastic waste into the third container.
示例测试用例的解释:
- Monocarp 可以将 1 件纸类垃圾放入第一个容器,将 2 件塑料类垃圾放入第二个容器,将 3 件普通垃圾放入第三个容器;
- Monocarp 可以将 1 件纸类垃圾和 1 件半纸类垃圾放入第一个容器,将 2 件塑料类垃圾放入第二个容器,将 3 件普通垃圾放入第三个容器;
- 无解,因为要么第二个容器应容纳 3 件物品,要么第三个容器应容纳 4 件物品;
- Monocarp 可以将 1 件纸类垃圾放入第一个容器,将 2 件塑料类垃圾放入第二个容器,将 3 件普通垃圾、1 件半纸类垃圾和 1 件半塑料类垃圾放入第三个容器;
- 完全没有垃圾,因此所有容器均可保持为空;
- 无解,因为不可能将纸类物品放入第三个容器;
- Monocarp 可以将 10 件半纸类垃圾放入第一个容器,将 37 件半塑料类垃圾放入第二个容器,将 30 件半纸类垃圾和 10 件半塑料类垃圾放入第三个容器。
输入解题思路,AI测评打分。不知道怎么写?