Code Forces 560 B. Gerald is into Art(水~)

Description
给出一个x*y的画框,现要向画框中放两幅画,必须水平竖直放且不能重合,问是否能放下
Input
六个整数分别表示画框及两幅画的长和宽
Output
若能放下则输出YES,否则输出NO
Sample Iuput
5 5
3 3
3 3
Sample Output
NO
Solution
简单题,暴力枚举所有情况,首先是两幅画的相切情况,即长长,宽宽,长宽,宽长四种情况,然后是在画框中的放置情况,即正放和侧放两种,所以是4*2=8种情况
Code

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a1,a2,b1,b2,x,y;
    scanf("%d%d%d%d%d%d",&x,&y,&a1,&b1,&a2,&b2);
    int flag=0;
    int c1=a1+a2,d1=max(b1,b2);
    int c2=a1+b2,d2=max(a2,b1);
    int c3=a2+b1,d3=max(a1,b2);
    int c4=b1+b2,d4=max(a1,a2);
    if(c1<=x&&d1<=y||c1<=y&&d1<=x)flag=1;
    if(c2<=x&&d2<=y||c2<=y&&d2<=x)flag=1;
    if(c3<=x&&d3<=y||c3<=y&&d3<=x)flag=1;
    if(c4<=x&&d4<=y||c4<=y&&d4<=x)flag=1;
    if(flag)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}

你可能感兴趣的:(Code Forces 560 B. Gerald is into Art(水~))