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

  

Codeforces Round #335 (Div. 2) A的更多相关文章

  1. Codeforces Round #335 (Div. 2) B. Testing Robots 水题

    B. Testing Robots Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest/606 ...

  2. Codeforces Round #335 (Div. 1) C. Freelancer's Dreams 计算几何

    C. Freelancer's Dreams Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contes ...

  3. Codeforces Round #335 (Div. 2) D. Lazy Student 构造

    D. Lazy Student Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/606/probl ...

  4. Codeforces Round #335 (Div. 2) C. Sorting Railway Cars 动态规划

    C. Sorting Railway Cars Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/conte ...

  5. Codeforces Round #335 (Div. 2) A. Magic Spheres 水题

    A. Magic Spheres Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest/606/ ...

  6. Codeforces Round #335 (Div. 2) D. Lazy Student 贪心+构造

    题目链接: http://codeforces.com/contest/606/problem/D D. Lazy Student time limit per test2 secondsmemory ...

  7. Codeforces Round #335 (Div. 2)

    水 A - Magic Spheres 这题也卡了很久很久,关键是“至少”,所以只要判断多出来的是否比需要的多就行了. #include <bits/stdc++.h> using nam ...

  8. 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. ...

  9. Codeforces Round #335 (Div. 2) D. Lazy Student 贪心

    D. Lazy Student   Student Vladislav came to his programming exam completely unprepared as usual. He ...

  10. Codeforces Round #335 (Div. 2) C. Sorting Railway Cars 连续LIS

    C. Sorting Railway Cars   An infinitely long railway has a train consisting of n cars, numbered from ...

随机推荐

  1. 【276】◀▶ Python 字符串函数说明

    参考:Python 字符串函数 01   capitalize 把字符串的第一个字符大写,其他字母变小写. 02   center 返回一个原字符串居中,并使用空格填充至长度 width 的新字符串. ...

  2. 企业级搜索引擎Solr 第三章 索引数据(Indexing Data)

    虽然本书中假设你要建索引的内容都是有着良好结构的,比如数据库表,XML文件,CSV,但在现实中我们要保存很混乱的数据,或是二进制文件,如PDF,Microsoft Office,甚至是图片和音乐文件. ...

  3. Angular22 HttpClient的使用

    1 HttpClient介绍 HttpClient时Http的演进,注意:Http在@angular/http中,而HttpClient在@angular/common/http中: 使用前需要在模块 ...

  4. 3、PACBIO下机数据如何看

    转载:http://www.cnblogs.com/jinhh/p/8328818.html 三代测序的下机数据都有哪些,以及他们具体的格式是怎么样的(以sequel 平台为主). 测序过程 SMRT ...

  5. EZOJ #73

    传送门 分析 我们知道如果对于模数$P$有$gcd(x,P) = 1$则$x$一定有且仅有一个逆元,可以表示为 $x \equiv \frac{y}{1} (mod P)$ 即为$xy \equiv ...

  6. Integer类的parseInt和valueOf的区别

    我们平时应该都用过或者见过parseInt和valueOf这两个方法.一般我们是想把String类型的字符数字转成int类型.从这个功能层面来说,这两个方法都一样,都可以胜任这个功能. 但是,我们进入 ...

  7. 关于IE6下绝对定位元素莫名消失的问题

    一般来说,让绝对定位的元素不挨着浮动元素就OK了: 1.当绝对定位层的邻近浮动层的宽度不等于父层宽度时,以及没有清除浮动时,IE6/7,FF中显示一致: 2.当绝对定位层的邻近浮动层的宽度不等于父层宽 ...

  8. C#中 ACCESS数据库常用操作语句...容易出错的地方(DateTime类型)

    这次在C#编程过程中,第一次用到了ACCESS数据库,重点涉及到时间类型,整数类型.是否类型....;遇到了许多困难,就把这些整理了下来,与大家分享. 一.Insert语句的基本格式: INSERT ...

  9. Win提权思路,方法,工具(小总结)[转]

    Win提权思路,方法,工具(小总结)[转] 看到这个文章,感觉整理的不错,就收藏下了. 介绍 windows提权总是被归结为适当的枚举.但要完成适当的枚举,你需要知道要检查和查找的内容.这通常需要伴随 ...

  10. 'module' object has no attribute 'contrib'

    Problem solved, turns i had 2 tensorflow versions installed: When launching $python , it used 0.6 ve ...