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/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 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 Input
4 4 0
2 1 2
Sample Output
Yes
HINT
题意
有三个物体
你现在分别有a,b,c个
你希望每种物品至少x,y,z个
然后两种相同的物品可以换成一个其他的物品
问你是否能够满足
题解:
贪心,首先,你拥有的超过需要的你才会变
然后你把这个数量记录下来,和你还差多少比一下就好了
代码:
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std; int a[];
int b[];
int main()
{
for(int i=;i<;i++)
cin>>a[i];
for(int i=;i<;i++)
cin>>b[i];
for(int i=;i<;i++)
a[i]=a[i]-b[i];
int flag1 = ,flag2 = ;
for(int i=;i<;i++)
{
if(a[i]>)
flag1+=a[i]/;
else
flag2+=a[i];
}
flag2 = -flag2;
if(flag1>=flag2)
printf("Yes\n");
else
printf("No\n");
}
Codeforces Round #335 (Div. 2) A. Magic Spheres 水题的更多相关文章
- 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. ...
- 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 ...
- Codeforces Round #367 (Div. 2) A. Beru-taxi (水题)
Beru-taxi 题目链接: http://codeforces.com/contest/706/problem/A Description Vasiliy lives at point (a, b ...
- Codeforces Round #334 (Div. 2) A. Uncowed Forces 水题
A. Uncowed Forces Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/pro ...
- Codeforces Round #353 (Div. 2) A. Infinite Sequence 水题
A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/675/problem/A Description Vasya likes e ...
- Codeforces Round #327 (Div. 2) A. Wizards' Duel 水题
A. Wizards' Duel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/prob ...
- Codeforces Round #146 (Div. 1) A. LCM Challenge 水题
A. LCM Challenge 题目连接: http://www.codeforces.com/contest/235/problem/A Description Some days ago, I ...
- Codeforces Round #306 (Div. 2) A. Two Substrings 水题
A. Two Substrings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/550/pro ...
- Codeforces Round #188 (Div. 2) A. Even Odds 水题
A. Even Odds Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/318/problem/ ...
随机推荐
- $("#province").val();取不到select的值求解
MVC下的razor视图开发中无法取到select的值问题求解 cshtml 如下 <select name="province" id="province&quo ...
- 将Tomcat注册为Windows服务
1.从官网http://tomcat.apache.org/下载Tomcat. 2.将Tomcat压缩文件解压到相应的路径下(例如E:\TomcatServer) 3.从bin目录下找到service ...
- spring依赖注入原理剖析
PropertyDefinition.java package junit.test; public class PropertyDefinition { private String name; p ...
- Exploit用法示例
一.msf> show exploits与msf> show payloads:这两条命令用于展示Metaploit目录中所有可用的漏洞利用代码和攻击载荷. 二.msf> searc ...
- MVC5 - ASP.NET Identity登录原理 - Claims-based认证和OWIN -摘自网络
在Membership系列的最后一篇引入了ASP.NET Identity,看到大家对它还是挺感兴趣的,于是来一篇详解登录原理的文章.本文会涉及到Claims-based(基于声明)的认证,我们会详细 ...
- Linux下oracle导入(exp)导出(imp)出现"Failed to open ...for reader/write"错误
- hdu5072-Coprime(容斥原理)
题意:给N个互不相同的数,选择出两两互质或者两两不互质的三个数,有多少种选法. 题解:一共有C(N,3)中选择方式,减去不符合要求的,剩下的就是答案. 详见 http://blog.csdn.net/ ...
- 第三百三十七天 how can I 坚持
看了两集<太阳的后裔>,你眼中的你自己,真实的你自己,他眼中的你,你眼中的他,他眼中的他自己,真实的他自己.好乱. 何须让别人懂你,何须让自己懂自己,将就着一天天过吧. 睡觉.
- unigui MessageDlg方法调用例子
procedure TfrmEmployee.btnDeleteClick(Sender: TObject);var aBool: Boolean;begin inherited; MessageDl ...
- 进入GRUB改root用户密码
开机读取倒计时时按任意键----e---->选择第二行 kernel ---->按e, 再按空格 >输入1----回车--->选择kernel输入b----> passw ...