前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【CodeForces 606A】A -特别水的题1-Magic Spheres

【CodeForces 606A】A -特别水的题1-Magic Spheres

作者头像
饶文津
发布2020-05-31 23:41:01
4760
发布2020-05-31 23:41:01
举报
文章被收录于专栏:饶文津的专栏饶文津的专栏

http://acm.hust.edu.cn/vjudge/contest/view.action?cid=102271#problem/A

Description

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 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 Input

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

Hint

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.

这题就是说两个相同的球可以变成一个任意一种球,现在问你能否得到各种球至少给定个?用当前的个数减去目标个数,如果是正数,多出来的可以拿去变成其它的,于是可以得到[差除以二]个其它球(整除),我们就ans+=差/2。如果是负数,就是需要变成[-差]那么多个,就ans+=差。最后ans是负数,则不能,否则能。

代码语言:javascript
复制
#include<stdio.h>
int main()
{
    long long a,b,c,x,y,z,ans=0;
    scanf("%lld%lld%lld%lld%lld%lld",&a,&b,&c,&x,&y,&z);
    a=a-x;
    b=b-y;
    c=c-z;
    if(a>0)ans+=a/2;
    else ans+=a;
    if(b>0)ans+=b/2;
    else ans+=b;
    if(c>0)ans+=c/2;
    else ans+=c;
    if(ans>=0)printf("Yes");
    else printf("No");
    return 0;
}
本文参与?腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2015-12-14 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客?前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与?腾讯云自媒体分享计划? ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
http://www.vxiaotou.com