[20191003 room test] Sky Dragon

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

This topic describes let me feel the machine turned to face the fear of ......
It's not a foreign language translation of the ah Hey! What language level?

Obviously, if there is extra color, they are ÷ 2, is the number that can be converted
and then compared with the color difference, the answer

Code:

#include<bits/stdc++.h>
using namespace std;

int T,delta,need;
struct Color
{
    int x,y;
}a[5];

bool cmp(Color a,Color b) {return (a.x-a.y)>(b.x-b.y);}

template<class T>inline void read(T &res)
{
    char c;T flag=1;
    while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
    while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}

int main()
{
    freopen("osiris.in","r",stdin);
    freopen("osiris.out","w",stdout);
    read(T);
    while(T--)
    {
        delta=need=0;
        for(register int i=1;i<=3;++i) read(a[i].x);
        for(register int i=1;i<=3;++i) read(a[i].y);
        for(register int i=1;i<=3;++i)
            if(a[i].x>a[i].y)
                delta+=(a[i].x-a[i].y)>>1;
        for(register int i=1;i<=3;++i)
            if(a[i].x<=a[i].y)
                need+=a[i].y-a[i].x;
        if(delta>=need) puts("YES");
        else puts("NO");
    }
    return 0;
}

Guess you like

Origin www.cnblogs.com/tqr06/p/11619760.html
sky