Codeforces Round #335 (Div. 2) A
2 seconds
256 megabytes
standard input
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)?
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.
If the wizard is able to obtain the required numbers of spheres, print "Yes". Otherwise, print "No".
4 4 0
2 1 2
Yes
5 6 1
2 7 2
No
3 3 3
2 2 2
Yes
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的更多相关文章
- 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 #335 (Div. 1) C. Freelancer's Dreams 计算几何
C. Freelancer's Dreams Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contes ...
- 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 ...
- 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 ...
- 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/ ...
- Codeforces Round #335 (Div. 2) D. Lazy Student 贪心+构造
题目链接: http://codeforces.com/contest/606/problem/D D. Lazy Student time limit per test2 secondsmemory ...
- Codeforces Round #335 (Div. 2)
水 A - Magic Spheres 这题也卡了很久很久,关键是“至少”,所以只要判断多出来的是否比需要的多就行了. #include <bits/stdc++.h> using nam ...
- 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) D. Lazy Student 贪心
D. Lazy Student Student Vladislav came to his programming exam completely unprepared as usual. He ...
- 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 ...
随机推荐
- div盒子模型
<style type="text/css"> div{ width:300px; height:300px; background:green; margin:10p ...
- 在Linux下adb连接不上android手机的终极解决方案
转自: http://blog.csdn.net/liuqz2009/article/details/7942569 1.做android开发的过程,碰到了Linux下adb识别不了android设备 ...
- ubuntu16搭建docker私库
测试环境如下: 一.docker的安装 安装方法请查看这里的 安装教程 二.设置普通用户 1. centos的设置方法 $ sudo gpasswd -a docker ${USER} 2. ubun ...
- js中的各种宽高
在设计页面时可能经常会用到固定层的位置,这就需要获取一些html对象的坐标以更灵活的设置目标层的坐标,这里可能就会用到document .body.scrollTop等属性,但是此属性在xhtml标准 ...
- Codeforces #495 Div2 problem E. Sonya and Ice Cream(1004E)
网上的大多是用树的直径做的,但是一些比较巧妙的做法,来自https://www.cnblogs.com/qldabiaoge/p/9315722.html. 首先用set数组维护每一个节点所连接的边的 ...
- 百度Apollo解析——3.common
1.略读 该目录下主要提供了各个模块公用的函数和class以及一些数学API还有公共的宏定义. 在Apollo 1.0中,common是整个框架的基础.configs是配置文件加载.adapters是 ...
- jqgrid列动态加载
private void InitGrid(string entityName) { Session["entityName"] = entityName; ArrayList c ...
- 连接Excel数据库
SQL语法:http://www.w3school.com.cn/sql/sql_syntax.asp Ctrl键拖(也就是复制) 先输入1,2,然后下拉 一.问题的提出 在ASP编程中会遇到很多大大 ...
- HUST高级软件工程--测试管理工具实践--Day2
测试管理工具实践--Day2 今天完成任务情况: 小靳 今天主要探索如何安装jira.在官网下载了最新版Windows64位jira,然后按照网上教程走,设置好端口号.在安装之前自以为这款软件在安装的 ...
- 关于C#中的算术运算
使用中间变量交换两个int型变量的值: ; ; a = a+b; b = a-b; a = a-b; 相信大家很容易写出来,但考虑到边界值情况时会有一些有趣的事情. 我们知道有一个int.MaxVal ...