您的位置:首页 > 编程语言 > C语言/C++

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

2015-12-10 13:42 387 查看
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 a, b 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, x, y 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)这样的关系
统计所有多出来的(每两个增加一个的兑换可能);统计所有不够的。
然后看看多出来的兑换可能能否抵消不够的即可。

*/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息