Gerald is into Art

Source: Internet
Author: User

Gerald is into Art

Gerald bought-very rare paintings at the Sotheby's auction and he now wants-hang them on the wall. For this he bought a special board to attach it to the wall and place the paintings on the board. The board has a shape of a1x b1 rectangle, and the paintings has a shape of a a 2x b 2 and a3x B3 rectangles.

Since The paintings is painted in the style of an abstract art, it does not matter exactly how they would be rotated, but STI ll, one side of both the board, and each of the paintings must is 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 was possible to place the paintings on the board, or was the board he bought not large enough?

Input

The first line contains space-separated numbers a1 and b1-the sides of the board. Next lines contain numbers a2, b2, a3 andB3- The sides of the paintings. All numbers ai, bi in the input is integers and fit into the R Ange from 1 to +.

Output

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

Input
3 2
1 3
2 1
Output
YES
Input
5 5
7 ·
7 ·
Output
NO
Input
4 2
2 3
1 2
Output
YES

Address: Http://codeforces.com/contest/560/problem/B

Idea: Test instructions is simple is to put 2 rectangles in a large rectangular, to see if they can succeed.
At first, when I thought about it, I forgot that there was only a 2 rectangle and it felt so hard. Finally looked at the next is 2.
So it was simple, but I didn't think of any good way. Consider the situation directly, should be 8 kinds.
finally on the AC, Baidu as if everyone is doing so, as to the situation of a number of rectangles have yet to be considered, there are other people's code details than I write simpler   .

#include <cstdio>using namespacestd;intMain () {intA1, B1; intA2, B2; intA3, B3;  while(SCANF ("%d%d", &AMP;A1, &b1)! =EOF) {scanf ("%d%d", &AMP;A2, &B2); scanf ("%d%d", &AMP;A3, &b3); intFlag =0; if((A2 * b2 + a3 * B3) > (A1 *B1)) {Flag=1; }                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=1; }                }                if(1==flag) {printf ("no\n"); }Else{printf ("yes\n"); }        }        return 0;}

    

2015-07-26 18:15:47

Gerald is into Art

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.