天空龙(osiris)

【问题描述】

奥西里斯之天空龙很喜欢颜色,有一天他找到了三种颜色——红 黄蓝。 奥西里斯有 a 个红色,b 个黄色,c 个蓝色,他想用画出最好的画, 可是需要至少 x 个红色,y 个黄色和 z 个蓝色,似乎并不够。别担心, 奥西里斯会魔法!他可以把任何两个同种颜色转化为一个另一种颜 色!请问他能不能完成呢?

【输入格式】 第一行一个正整数 t 表示数据组数。 接下来 t 行每行六个整数分别表示 a,b,c,x,y,z。

【输出格式】

每组数据输出一行,如果可以就输出“YES”,否则输出“NO”。

【样例输入输出】

输入

 3

4 4 0 2 1 2

5 6 1 2 7 2

扫描二维码关注公众号,回复: 7786964 查看本文章

3 3 3 2 2 2

输出

YES

NO

YES

【数据范围与约定】

对于 100%的数据 t<=100,0<=a,b,c,x,y,z<=1000000。

#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
int t,a,b,c,x,y,z;
int read(){
	int a=0,b=1;
	char ch=getchar();
	while((ch<'0'||ch>'9')&&(ch!='-')){
		ch=getchar();
	}
	if(ch=='-'){
		b=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		a=a*10+ch-'0';
		ch=getchar();
	}
	return a*b;
}
int main(){
	freopen("osiris.in","r",stdin);
	freopen("osiris.out","w",stdout);
	t=read();
	while(t--){
		a=read(),b=read(),c=read(),x=read(),y=read(),z=read();
		if(a>=x){
			a-=x;
			x=0;
		}
		else{
			x-=a;
			a=0;
		}
		if(b>=y){
			b-=y;
			y=0;
		}
		else{
			y-=b;
			b=0;
		}
		if(c>=z){
			c-=z;
			z=0;
		}
		else{
			z-=c;
			c=0;
		}
		int s=(a/2)+(b/2)+(c/2);
		s-=(x+y+z);
		if(s<0){
			printf("NO\n");
		}
		if(s>=0){
			printf("YES\n");
		}
	}
	return 0;
}
	

  

猜你喜欢

转载自www.cnblogs.com/xiongchongwen/p/11819965.html