Gerald is into Art

Gerald bought two very rare paintings at the Sotheby's auction and he now wants to hang them on the wall. For that he bought a special board to attach it to the wall and place the paintings on the board. The board has shape of an a1 × b1 rectangle, the paintings have shape of a a2 × b2 and a3 × b3 rectangles.

Since the paintings are painted in the style of abstract art, it does not matter exactly how they will be rotated, but still, one side of both the board, and each of the paintings must be parallel to the floor. The paintings can touch each other and the edges of the board, but can not overlap or go beyond the edge of the board. Gerald asks whether it is possible to place the paintings on the board, or is the board he bought not large enough?

Input

The first line contains two space-separated numbers a1 and b1 — the sides of the board. Next two lines contain numbers a2, b2, a3 andb3 — the sides of the paintings. All numbers ai, bi in the input are integers and fit into the range from 1 to 1000.

Output

If the paintings can be placed on the wall, print "YES" (without the quotes), and if they cannot, print "NO" (without the quotes).

input
3 21 32 1
output
YES
input
5 53 33 3
output
NO
input
4 22 31 2
output
YES

地址:http://codeforces.com/contest/560/problem/B思路:题意很简单就是把2个长方形放在一个大的长方形的里,看是否能成功。     刚开始,在想的时候,忘了只有个2个长方形,感觉好难。最后再看了下是2个。。     于是就简单了,但是也没有想到什么好办法。直接考虑所以的情况,应该是8种。    最后就AC了,百度了下好像大家都是这么做的,至于多个长方形的情况还有待考虑,还有别人的代码细节写的比我简单些。
#include <cstdio>

using namespace std;

int main(){

        int a1, b1;
        int a2, b2;
        int a3, b3;

        while(scanf("%d%d", &a1, &b1) != EOF){
                scanf("%d%d", &a2, &b2);
                scanf("%d%d", &a3, &b3);

                ;

                if((a2 * b2 + a3 * b3) > (a1 * b1)){
                        flag = ;
                }
                else{
                        if((a2 + a3) <= a1  && b2 <= b1 && b3 <= b1){
                        }
                        else if((a2 + b3) <= a1 && b2 <= b1 && a3 <= b1){
                        }
                        else if((a2 <= a1 && a3 <= a1 && (b2 + b3) <= b1)){
                        }
                        else if(a2 <= a1 && b3 <= a1 && (b2 + a3) <= b1){
                        }
                        else if((b2 + a3) <= a1 && a2 <= b1 && b3 <= b1){
                        }
                        else if((b2 + b3) <= a1 && a2 <= b1 && a3 <= b1){
                        }
                        else if(b2 <= a1 && a3 <= a1 && (a2 + b3) <= b1){
                        }
                        else if(b2 <= a1 && b3 <= a1 && (a2 + a3) <= b1){
                        }
                        else{
                                flag = ;
                        }
                }
                 == flag){
                        printf("NO\n");
                }else{
                        printf("YES\n");
                }
        }
        ;
}

    

        2015-07-26  18:15:47

Gerald is into Art的更多相关文章

  1. Codeforces Round #313 (Div. 2)B.B. Gerald is into Art

    B. Gerald is into Art Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/ ...

  2. CodeForces 560B Gerald is into Art

     Gerald is into Art time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  3. Codeforces Round #313 (Div. 2) B. Gerald is into Art 水题

    B. Gerald is into Art Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/560 ...

  4. B. Gerald is into Art

    B. Gerald is into Art time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  5. 【打CF,学算法——二星级】Codeforces Round #313 (Div. 2) B. Gerald is into Art(水题)

    [CF简单介绍] 提交链接:http://codeforces.com/contest/560/problem/B 题面: B. Gerald is into Art time limit per t ...

  6. Codeforces Round #313 B. Gerald is into Art(简单题)

    B. Gerald is into Art time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  7. 【45.65%】【codeforces 560B】Gerald is into Art

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  8. CodeForces 567A Gerald is into Art

    http://codeforces.com/problemset/problem/567/A A. Lineland Mail time limit per test 3 seconds memory ...

  9. Codeforces Round #313 (Div. 2) A.B,C,D,E Currency System in Geraldion Gerald is into Art Gerald's Hexagon Equivalent Strings

    A题,超级大水题,根据有没有1输出-1和1就行了.我沙茶,把%d写成了%n. B题,也水,两个矩形的长和宽分别加一下,剩下的两个取大的那个,看看是否框得下. C题,其实也很简单,题目保证了小三角形是正 ...

随机推荐

  1. JVM之几种垃圾收集器简单介绍

    本文中的垃圾收集器研究背景为:HotSpot+JDK1.7 一.垃圾收集器概述 如上图所示,垃圾回收算法一共有7个,3个属于年轻代.三个属于年老代,G1属于横跨年轻代和年老代的算法. JVM会从年轻代 ...

  2. js爬虫心得

    第一步:分析要爬的网站:包括是否需要登陆.点击下一页的网址变化.下拉刷新的网址变化等等 第二步:根据第一步的分析,想好爬这个网站的思路 第三步:爬好所需的内容 保存 爬虫过程中用到的一些包: (1)c ...

  3. sql常用单行函数

    学到数据库了,小记一下的喽~~~>>>>常用的单行函数 select * from employees 查询所有 select first_name,lower(first_n ...

  4. ANGULAR JS WATCH监听使用(详)

    ANGULAR 监听使用: 当angular数据模型发生变化时,我们需要如果需要根据他的变化触发其他的事件. $watch是一个scope函数,用于监听模型变化,当你的模型部分发生变化时它会通知你. ...

  5. js_保留关键字

    网页可以被我们分为三个大的部分:结构,表现,形式而js就是专对于表现的,js是一门编程的解释性脚本语言,和其他的语言相同js也有自己的保留的关键字,下面我们来看看js保留的关键字吧!js一共有56个关 ...

  6. 更新maven库

    删除所在本地仓库的文件夹,例如: 然后,重新下载一个jar包,放到工程的文件夹,注意名字要不同,否则maven库不予更新,替换完成后,点击工程,maven,update project即可,再次查看M ...

  7. HDU2586How far away ?

    http://acm.hdu.edu.cn/showproblem.php?pid=2586 How far away ? Time Limit: 2000/1000 MS (Java/Others) ...

  8. 俄罗斯画师Mikhail Rakhmatullin作品

  9. php : 配置

    一. php: undefined function mysql_connect()  mac 上操作 一.有可能是因为版本不同而引起的 PHP5中使用mysql_connect()函数进行连接.但P ...

  10. IE7中绝对定位元素之间的遮盖问题

    由于页面复杂就不上现实例子,举例说明. 两个同层级<div>元素,都设置了 position: relative;相对定位. 他们的内部的元素(不管什么元素了)都设置了position: ...