Codeforces Round #335 (Div. 2) A

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 and z 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 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;
}

  

 

转载于:https://www.cnblogs.com/yinghualuowu/p/5037135.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值