CodeforcesAug 06, 2025

Got Any Grapes?

Hazrat Ali

Codeforces

Andrew, Dmitry and Michal are all grapes' lovers, however their preferences of grapes are different. To make all of them happy, the following should happen:

  • Andrew, Dmitry and Michal should eat at least xy and z grapes, respectively.
  • Andrew has an extreme affinity for green grapes, thus he will eat green grapes and green grapes only.
  • On the other hand, Dmitry is not a fan of black grapes — any types of grapes except black would do for him. In other words, Dmitry can eat green and purple grapes.
  • Michal has a common taste — he enjoys grapes in general and will be pleased with any types of grapes, as long as the quantity is sufficient.

Knowing that his friends are so fond of grapes, Aki decided to host a grape party with them. He has prepared a box with a green grapes, b purple grapes and c black grapes.

However, Aki isn't sure if the box he prepared contains enough grapes to make everyone happy. Can you please find out whether it's possible to distribute grapes so that everyone is happy or Aki has to buy some more grapes?

It is not required to distribute all the grapes, so it's possible that some of them will remain unused.

Input

The first line contains three integers xy and z (1x,y,z10) — the number of grapes Andrew, Dmitry and Michal want to eat.

The second line contains three integers abc (1a,b,c10) — the number of green, purple and black grapes in the box.

Output

If there is a grape distribution that allows everyone to be happy, print "YES", otherwise print "NO".

Examples
Input
1 6 2
4 3 3
Output
YES
Input
5 1 1
4 3 2
Output
NO


Solution

#include <bits/stdc++.h>
using namespace std;

int main()
{


    int x, y, z;
    cin >> x >> y >> z;
    int a, b, c;
    cin >> a >> b >> c;
    bool c1 = a >= x;
    bool c2 = a - x + b >= y;
    bool c3 = a + b - x - y + c >= z;
    if (c1 and c2 and c3)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}







Comments