【Codeforces Round 335 (Div 2) A】【水题】Magic Spheres 三种类型物品兑换比例2:1.cpp
2015-12-10 13:42
387 查看
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
andz 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 test(s)
input
output
input
output
input
output
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.
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
andz 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 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.
#include<stdio.h> #include<iostream> #include<string.h> #include<string> #include<ctype.h> #include<math.h> #include<set> #include<map> #include<vector> #include<queue> #include<bitset> #include<algorithm> #include<time.h> using namespace std; void fre(){freopen("c://test//input.in","r",stdin);freopen("c://test//output.out","w",stdout);} #define MS(x,y) memset(x,y,sizeof(x)) #define MC(x,y) memcpy(x,y,sizeof(x)) #define MP(x,y) make_pair(x,y) #define ls o<<1 #define rs o<<1|1 typedef long long LL; typedef unsigned long long UL; typedef unsigned int UI; template <class T1,class T2>inline void gmax(T1 &a,T2 b){if(b>a)a=b;} template <class T1,class T2>inline void gmin(T1 &a,T2 b){if(b<a)a=b;} const int N=0,M=0,Z=1e9+7,ms63=1061109567; int a,b,c,x,y,z; int main() { while(~scanf("%d%d%d%d%d%d",&a,&b,&c,&x,&y,&z)) { int more=0,need=0; if(a>x)more+=a-x>>1; else need+=x-a; if(b>y)more+=b-y>>1; else need+=y-b; if(c>z)more+=c-z>>1; else need+=z-c; puts(more>=need?"Yes":"No"); } return 0; } /* 【trick&&吐槽】 又傻叉了,水题不过脑,还错TwT 【题意】 有3种类型的物品,个数分别是a,b,c个 我们可以使用一种类型的物品,到黑市商人那里以2:1的比例兑换我们想要的其他类型的物品。 问你最终是否能使得3种类型的物品至少为x,y,z个。 【类型】 水题 【分析】 我们(a,x)(b,y)(c,z)这样的关系 统计所有多出来的(每两个增加一个的兑换可能);统计所有不够的。 然后看看多出来的兑换可能能否抵消不够的即可。 */
相关文章推荐
- HDU 5240 Exam (好水的题)
- 北大—1006——Biorhythms
- 时间计算(heaven.pas/cpp)
- 工作依赖(job.cpp/pas)
- 题目 英雄 (BFS)
- kmp 学习 hihocoder #1015
- HDU 1096 A+B for Input-Output Practice (VIII)
- P1478
- P1035
- P1008 难度2.7
- 2020 绝对值排序
- 2021 发工资咯
- 2022 海选女主角
- 2024 C语言合法标识符
- 2025 查找最大元素
- 2026 首字母变大写
- 2027 统计元音
- 2028 Lowest Common Multiple Plus
- 2018 母牛的故事
- 2023 求平均成绩