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/ ...
随机推荐
- APP测试时不可忽视搭建代理服务器抓包测试的必要性
这几天测的一个app,后台从已有服务器搬迁到了阿里云,接口api之类的都没有变化,但测试时发现客户端始终无法使用,每次点击都无法获得服务器反馈 用python编写脚本调接口,没问题,返回数据一切正常, ...
- CSS概述<选择器总结>
概述:CSS是指层叠样式表,他是定义如何显示HTML元素,样式表通常存储在样式表中,通常存储在.css文件中,下面对css的选择器进行总结,便大家夯实基础! 1 语法规范: 每个样式规则有两个部分:选 ...
- XML Schema 简介
XML Schema 是基于 XML 的 DTD 替代者. XML Schema 可描述 XML 文档的结构. XML Schema 语言也可作为 XSD(XML Schema Definition) ...
- C++C#时间转换
time_t是从1970年1月1日的格林尼治时间开始的,所以以下就是你要的结果System.DateTime time= new System.DateTime(1970, 1, 1).ToLocal ...
- 【转载】Python中如何高效实现两个字典合并,三种方法比较。
本文转载自:http://www.pythoner.com/13.html Python中将两个字典进行合并操作,是一个比较常见的问题.本文将介绍几种实现两个字典合并的方案,并对其进行比较. 对于这个 ...
- js中location.search、split()HTML5中localStorage
1. location.search在客户端获取Url参数的方法 location.search是从当前URL的?号开始的字符串 如:http://www.baidu.com/s?wd=baidu&a ...
- javascript常用的小知识
1. oncontextmenu="window.event.returnvalue=false" 将彻底屏蔽鼠标右键 <table border oncontextmenu ...
- HttpClient 操作总结
1.HttpClient4.3和之前版本设置超时(set timeout)区别: 参考:http://my.oschina.net/u/577453/blog/173724 解析:如果不设置超时的话, ...
- RSS阅读器&BT sync
①RSS阅读器? 答:RSS阅读器是一种软件或是说一个程序,这种软件可以自由读取RSS和Atom两种规范格式的文档,且这种读取RSS和Atom文档的软件有多个版本,由不同的人或公司开发,有着不同的名字 ...
- javascript压缩图片无刷新上传
首先要说明,该方式我没有实现成功,主要问题点是压缩后能拿到压缩后图片地址,确不知道怎么上传上去,如果有哪位大牛可以指点一二,万分感谢. 图片压缩代码: compress: function(sourc ...