贪心 D - Got Any Grapes?

题目
The Duck song
For simplicity, we’ll assume that there are only three types of grapes: green grapes, purple grapes and black grapes.

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 x, y 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 x, y and z (1≤x,y,z≤105) — the number of grapes Andrew, Dmitry and Michal want to eat.

The second line contains three integers a, b, c (1≤a,b,c≤105) — 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
Note
In the first example, there is only one possible distribution:

Andrew should take 1 green grape, Dmitry should take 3 remaining green grapes and 3 purple grapes, and Michal will take 2 out of 3 available black grapes.

In the second test, there is no possible distribution, since Andrew is not be able to eat enough green grapes. 😦

#include <stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int a = 0, b = 0, c = 0, x = 0, y = 0, z = 0;
	scanf("%d%d%d%d%d %d",&x,&y,&z,&a,&b,&c);
	if (x <= a && x + y <= a + b && x + y + z <= a + b + c)
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值