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 and z orange spheres. Can he get them (possible, in multiple actions)?
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.
If the wizard is able to obtain the required numbers of spheres, print "Yes". Otherwise, print "No".
4 4 0
2 1 2
Yes
5 6 1
2 7 2
No
3 3 3
2 2 2
Yes
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 2orange spheres, which is exactly what he needs.
题意:有 a b c 三种东西,2个a可以换一个b或一个c,其他种类也是相同的换法 问可不可以换成想要的种类数量
如果想要的比以前的少了,绝对是两个拿去换一个了,所以是(a-x)/2看能换多少个;如果多了,绝对是其他种类两个换它一个了,那我就减去能换的
#include<stdio.h>
//#include<bits/stdc++.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<sstream>
#include<set>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>
#include<limits.h>
#define inf 0x3fffffff
#define INF 0x3f3f3f3f
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define ULL unsigned long long
using namespace std;
int i,j;
int n,m;
int sum,ans,flag;
//int a[1000000];
int t;
int a,b,c;
int x,y,z;
int main()
{
cin>>a>>b>>c;
cin>>x>>y>>z;
sum=0;
if(a-x>=0)
{
sum+=(a-x)/2;
}
else if(a-x<0)
{
sum-=(x-a);
}
if(b-y>=0)
{
sum+=(b-y)/2;
}
else if(b-y<0)
{
sum-=(y-b);
}
if(c-z>=0)
{
sum+=(c-z)/2;
}
else if(c-z<0)
{
sum-=(z-c);
}
if(sum>=0)
{
puts("Yes");
}
else
{
puts("No");
}
return 0;
}