CF1371C.A Cookie for You
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Anna is a girl so brave that she is loved by everyone in the city and citizens love her cookies. She is planning to hold a party with cookies. Now she has a vanilla cookies and b chocolate cookies for the party.
She invited n guests of the first type and m guests of the second type to the party. They will come to the party in some order. After coming to the party, each guest will choose the type of cookie (vanilla or chocolate) to eat. There is a difference in the way how they choose that type:
If there are v vanilla cookies and c chocolate cookies at the moment, when the guest comes, then
- if the guest of the first type: if v>c the guest selects a vanilla cookie. Otherwise, the guest selects a chocolate cookie.
- if the guest of the second type: if v>c the guest selects a chocolate cookie. Otherwise, the guest selects a vanilla cookie.
After that:
- If there is at least one cookie of the selected type, the guest eats one.
- Otherwise (there are no cookies of the selected type), the guest gets angry and returns to home.
Anna wants to know if there exists some order of guests, such that no one guest gets angry. Your task is to answer her question.
安娜是一位非常勇敢的女孩,深受全城人民的喜爱,大家也都喜欢她做的饼干。她正计划举办一场饼干派对。目前,她准备了 a 块香草味饼干和 b 块巧克力味饼干。
她邀请了 n 位第一类客人和 m 位第二类客人参加派对。这些客人会以某种顺序陆续抵达派对现场。每位客人到达后,将选择一种饼干(香草味或巧克力味)来食用。他们选择的方式有所不同:
假设某位客人到达时,现场尚有 v 块香草味饼干和 c 块巧克力味饼干,则:
- 若该客人属于第一类:当 v>c 时,他选择香草味饼干;否则,他选择巧克力味饼干。
- 若该客人属于第二类:当 v>c 时,他选择巧克力味饼干;否则,他选择香草味饼干。
随后:
- 若所选类型的饼干至少还剩一块,该客人就吃掉其中一块;
- 否则(即所选类型的饼干已全部耗尽),该客人会生气并愤然离场。
安娜想知道:是否存在某种客人到场的顺序,使得没有任何一位客人会生气离场?你的任务就是回答这个问题。
输入格式
The input consists of multiple test cases. The first line contains a single integer t (1≤t≤1000) — the number of test cases. Next t lines contain descriptions of test cases.
For each test case, the only line contains four integers a, b, n, m (0≤a,b,n,m≤1018,n+m=0).
输入包含多个测试用例。第一行包含一个整数 t(1≤t≤1000),表示测试用例的数量。接下来的 t 行描述了各个测试用例。
对于每个测试用例,唯一的一行包含四个整数 a、b、n、m(0≤a,b,n,m≤1018,且 n+m=0)。
输出格式
For each test case, print the answer in one line. If there exists at least one valid order, print "Yes". Otherwise, print "No".
You can print each letter in any case (upper or lower).
对于每个测试用例,在一行中输出答案。如果至少存在一种合法的顺序,则输出“Yes”;否则输出“No”。
你可以以任意大小写(大写或小写)输出每个字母。
输入输出样例
输入#1
6 2 2 1 2 0 100 0 1 12 13 25 1 27 83 14 25 0 0 1 0 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000
输出#1
Yes No No Yes No Yes
说明/提示
In the first test case, let's consider the order 1,2,2 of types of guests. Then:
- The first guest eats a chocolate cookie. After that, there are 2 vanilla cookies and 1 chocolate cookie.
- The second guest eats a chocolate cookie. After that, there are 2 vanilla cookies and 0 chocolate cookies.
- The last guest selects a chocolate cookie, but there are no chocolate cookies. So, the guest gets angry.
So, this order can't be chosen by Anna.
Let's consider the order 2,2,1 of types of guests. Then:
- The first guest eats a vanilla cookie. After that, there is 1 vanilla cookie and 2 chocolate cookies.
- The second guest eats a vanilla cookie. After that, there are 0 vanilla cookies and 2 chocolate cookies.
- The last guest eats a chocolate cookie. After that, there are 0 vanilla cookies and 1 chocolate cookie.
So, the answer to this test case is "Yes".
In the fifth test case, it is illustrated, that the number of cookies (a+b) can be equal to zero, but the number of guests (n+m) can't be equal to zero.
In the sixth test case, be careful about the overflow of 32-bit integer type.
在第一个测试用例中,考虑客人类型序列 {1,2,2}。此时:
- 第一位客人吃掉一块巧克力饼干。之后,剩余 2 块香草饼干和 1 块巧克力饼干。
- 第二位客人吃掉一块巧克力饼干。之后,剩余 2 块香草饼干和 0 块巧克力饼干。
- 最后一位客人想选择一块巧克力饼干,但已无巧克力饼干剩余。因此,该客人会生气。
所以,该序列不能被安娜选用。
再考虑客人类型序列 {2,2,1}。此时:
- 第一位客人吃掉一块香草饼干。之后,剩余 1 块香草饼干和 2 块巧克力饼干。
- 第二位客人吃掉一块香草饼干。之后,剩余 0 块香草饼干和 2 块巧克力饼干。
- 最后一位客人吃掉一块巧克力饼干。之后,剩余 0 块香草饼干和 1 块巧克力饼干。
因此,该测试用例的答案为“Yes”。
在第五个测试用例中,图示说明饼干总数(a+b)可以为零,但客人总数(n+m)不能为零。
在第六个测试用例中,请注意 32 位整数类型的溢出问题。
输入解题思路,AI测评打分。不知道怎么写?