A13472 | A Cookie for You
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
The input consists of multiple test cases. The first line contains a single integer $t$ ( $1 \le t \le 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 \le a,b,n,m \le 10^{18}, n+m \neq 0$ ).
For each test case, the only line contains four integers $a$ , $b$ , $n$ , $m$ ( $0 \le a,b,n,m \le 10^{18}, n+m \neq 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).
You can print each letter in any case (upper or lower).
输入输出样例
输入 #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.
- 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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted