【Codeforces Round 335 (Div 2) A】【水题】Magic Spheres 三种类型物品兑换比例2:1.cpp

A. Magic Spheres
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Carl is a beginner magician. He has a blue, b violet and c orange magic spheres. In one move he can transform two spheres of the same color into one sphere of any other color. To make a spell that has never been seen before, he needs at least x blue, y violet andz orange spheres. Can he get them (possible, in multiple actions)?

Input

The first line of the input contains three integers ab and c (0 ≤ a, b, c ≤ 1 000 000) — the number of blue, violet and orange spheres that are in the magician's disposal.

The second line of the input contains three integers, xy and z (0 ≤ x, y, z ≤ 1 000 000) — the number of blue, violet and orange spheres that he needs to get.

Output

If the wizard is able to obtain the required numbers of spheres, print "Yes". Otherwise, print "No".

Sample test(s)
input
4 4 0
2 1 2
output
Yes
input
5 6 1
2 7 2
output
No
input
3 3 3
2 2 2
output
Yes
Note

In the first sample the wizard has 4 blue and 4 violet spheres. In his first action he can turn two blue spheres into one violet one. After that he will have 2 blue and 5 violet spheres. Then he turns 4 violet spheres into 2 orange spheres and he ends up with 2 blue, 1 violet and 2 orange spheres, which is exactly what he needs.


#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre(){freopen("c://test//input.in","r",stdin);freopen("c://test//output.out","w",stdout);}
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x,y) memcpy(x,y,sizeof(x))
#define MP(x,y) make_pair(x,y)
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1,class T2>inline void gmax(T1 &a,T2 b){if(b>a)a=b;}
template <class T1,class T2>inline void gmin(T1 &a,T2 b){if(b<a)a=b;}
const int N=0,M=0,Z=1e9+7,ms63=1061109567;
int a,b,c,x,y,z;
int main()
{
	while(~scanf("%d%d%d%d%d%d",&a,&b,&c,&x,&y,&z))
	{
		int more=0,need=0;
		if(a>x)more+=a-x>>1;
		else need+=x-a;
		if(b>y)more+=b-y>>1;
		else need+=y-b;
		if(c>z)more+=c-z>>1;
		else need+=z-c;
		puts(more>=need?"Yes":"No");
	}
	return 0;
}
/*
【trick&&吐槽】
又傻叉了,水题不过脑,还错TwT

【题意】
有3种类型的物品,个数分别是a,b,c个
我们可以使用一种类型的物品,到黑市商人那里以2:1的比例兑换我们想要的其他类型的物品。
问你最终是否能使得3种类型的物品至少为x,y,z个。

【类型】
水题

【分析】
我们(a,x)(b,y)(c,z)这样的关系
统计所有多出来的(每两个增加一个的兑换可能);统计所有不够的。
然后看看多出来的兑换可能能否抵消不够的即可。

*/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值