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)?
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
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define maxn 100000+50
int main()
{
#ifdef CDZSC_June
freopen("t.txt","r",stdin);
#endif
int a[4],b[4],sum = 0;
scanf("%d%d%d",&a[0],&a[1],&a[2]);
scanf("%d%d%d",&b[0],&b[1],&b[2]);
for(int i = 0; i<3; i++)
{
if((a[i] - b[i]) < 0)
{
sum += a[i] - b[i];
}
else
{
sum += (a[i] - b[i])/2;
}
}
puts(sum >= 0?"Yes":"No");
}