Codeforces Round #335 (Div. 2) A. Magic Spheres 模拟

A. Magic Spheres
 

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.

 题意:给你三种球数量分别是a,b,c,对于两个相同的球可以转化为任意一个其他球,现在问你能否得到至少x,y,z三种球的数量

题解:

       对于a-x,大于0,则价值为(a-x)/2;小于0,则价值为(a-x);b,c类似,最后判断价值是否为正就好了

//meek
///#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <sstream>
#include <vector>
using namespace std ;
typedef long long ll;
#define mem(a) memset(a,0,sizeof(a))
#define pb push_back
#define fi first
#define se second
#define MP make_pair
inline ll read()
{
    ll x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
//****************************************

const int N=500000+100;
const ll inf = 1ll<<61;
const int mod= 1000000007;


int main() {
    int a,b,c,x,y,z;
    scanf("%d%d%d",&a,&b,&c);
    scanf("%d%d%d",&x,&y,&z);
    int aa=a-x;
    int bb=b-y;
    int cc=c-z;
    ll tmp=0;
    if(aa>0) {
        tmp+=(aa/2);
    }
    else tmp+=(aa);
    if(bb>0) {
        tmp+=(bb/2);
    }
    else{
        tmp+=(bb);
    }
    if(cc>0) {
        tmp+=(cc/2);
    }
    else tmp+=(cc);
    if(tmp>=0) {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;

    return 0;
}
代码

 

 

posted @ 2015-12-10 11:10  meekyan  阅读(214)  评论(0编辑  收藏  举报