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/ ...
随机推荐
- 解决 winform 界面对不齐 z
一个winform的程序,本机上界面对得很齐,到一到客户的机器上就惨不忍睹,一番研究后搞定: 1. AutoScaleMode = None 2. BackgroundImageLayout = No ...
- OSX学习02之更新输入法
OSX下最好的输入法是什么?话说在使用Windows的时候就知道了——它叫鼠须管. 想必大家用Windows的时候,进入系统第一步就是先装输入法吧~ OSX也是一样,自带输入法虽然凑合,但是我们作为A ...
- [转] 編程風格要素-The Elements of Programming Style 中文英文中英對照
转自: http://www.loliman3000.com/tech/2fe33ce32906f0302412881.php 下面的程序風格規則提煉自Brian Kernighan和P. J. Pl ...
- 哈希(Hash)与加密(Encrypt)的基本原理、区别及工程应用
0.摘要 今天看到吉日嘎拉的一篇关于管理软件中信息加密和安全的文章,感觉非常有实际意义.文中作者从实践经验出发,讨论了信息管理软件中如何通过哈希和加密进行数据保护.但是从文章评论中也可以看出很多朋友对 ...
- golang实现ios推送
生成pem文件 打开Keychain Access 导出推送证书和私钥 推送证书 cert.p12 私钥 key.p12 导出.pem文件 转换推送证书 openssl pkcs12 -clcerts ...
- hadoop 伪分布模式的配置
转自 http://blog.csdn.net/zhaogezhuoyuezhao/article/details/7328313 centos系统自带ssh,版本为openssh4.3 免密码ssh ...
- 基于Linux2.6内核的加密容器法保护文件方法
本文出自 "李晨光原创技术博客" 博客,谢绝转载!
- 第二百二十四天 how can I 坚持
实物商品兑换,有点小难搞,其实也没什么难的,也就那些东西,不过好像这就是我设计实现的,干起来挺来劲的. 供暖了,挺暖和的,哈哈. 小米耳机(炫彩版)到了.感觉挺好的. 还在纠结到底要买哪种颜色的羽绒服 ...
- cocos2d-x3.2 使用开关控制按钮 ControlSwitch
ContolSwitch 控件起到了一个开关的作用类似于现实生活中的开关,直接上代码: .h文件 // // SwitchBtnScene.h // LSWGameIOS // // Created ...
- 【MySQL】源码编译安装和配置MySql 5.5.32(单实例)
[需求描述] 在CentOS环境中,通过编译源码的方式,安装并且配置“单实例”的MySQL5.5.32数据库. MySQL的安装目录为:/application/mysql-5.5.32 MySQL数 ...