C. A Cookie for You

194 篇文章 1 订阅
44 篇文章 0 订阅

链接:https://codeforces.ml/contest/1371/problem/C

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 aa vanilla cookies and bb chocolate cookies for the party.

She invited nn guests of the first type and mm 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 vv vanilla cookies and cc chocolate cookies at the moment, when the guest comes, then

  • if the guest of the first type: if v>cv>c the guest selects a vanilla cookie. Otherwise, the guest selects a chocolate cookie.
  • if the guest of the second type: if v>cv>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.

Input

The input consists of multiple test cases. The first line contains a single integer tt (1≤t≤10001≤t≤1000) — the number of test cases. Next tt lines contain descriptions of test cases.

For each test case, the only line contains four integers aa, bb, nn, mm (0≤a,b,n,m≤1018,n+m≠00≤a,b,n,m≤1018,n+m≠0).

Output

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).

Example

input

Copy

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

output

Copy

Yes
No
No
Yes
No
Yes

Note

In the first test case, let's consider the order {1,2,2}{1,2,2} of types of guests. Then:

  • The first guest eats a chocolate cookie. After that, there are 22 vanilla cookies and 11 chocolate cookie.
  • The second guest eats a chocolate cookie. After that, there are 22 vanilla cookies and 00 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}{2,2,1} of types of guests. Then:

  • The first guest eats a vanilla cookie. After that, there is 11 vanilla cookie and 22 chocolate cookies.
  • The second guest eats a vanilla cookie. After that, there are 00 vanilla cookies and 22 chocolate cookies.
  • The last guest eats a chocolate cookie. After that, there are 00 vanilla cookies and 11 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+ba+b) can be equal to zero, but the number of guests (n+mn+m) can't be equal to zero.

In the sixth test case, be careful about the overflow of 3232-bit integer type.

代码:

#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll t,n,k,r,s,a,b,m;
int main()
{
   cin>>t;
   while(t--)
   {
       cin>>a>>b>>n>>m;
       if(n+m>a+b)
       cout<<"No"<<endl;
       else{
            if(a>b)
                swap(a,b);
            if(b-a>=n)
            {
                b-=n;
                n=0;
            }
            else
            {
                n-=b-a;
                b=a;
            }
            k=min(n,m);
            b-=k;
            a-=k;
            n-=k;
            m-=k;
            a-=m;
            if(a>=0&&b>=0)
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
       }
   }
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值