"Play CF, learn algorithm--Two star" Codeforces Round #313 (Div. 2) B. Gerald is into Art (water problem)

Source: Internet
Author: User

"CF Brief Introduction"

Submit Link: Http://codeforces.com/contest/560/problem/B


Surface:

B. Gerald is into Arttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard OUTPU T

Gerald bought-very rare paintings at the Sotheby ' s auction and he now wants to 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 shape of An a 1?x? b 1 rectangle, the paintings has shape of A a 2?x? b 2 and a 3?x? b 3 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 andb1 -the Sides of the board. Next lines contain numbersa2,? b2,? A3 andb3 -the sides of the paintings. All numbersai,? bi in the input is integers and fit into the range from1 to+.

Output

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

Sample Test (s) Input
3 21 32 1
Output
YES
Input
5 53 33 3
Output
NO
Input
4 22 31 2
Output
YES
Note

That's how we can place the pictures in the first test:

And that's how we can does it in the third one.

Solving:

is to see if we can put two pieces of paint. Put in the board, requires that the drawing must be parallel to the board.


Code:

#include <iostream> #include <algorithm> #include <cstdio>using namespace Std;int main () {int L1,W1,L2    , W2,L3,W3;    scanf ("%d%d", &AMP;L1,&AMP;W1);    scanf ("%d%d", &AMP;L2,&AMP;W2);    scanf ("%d%d", &AMP;L3,&AMP;W3);    BOOL Flag=false;    if ((L2+L3) <=l1&& (W2&LT;=W1&AMP;&AMP;W3&LT;=W1)) flag=true;    else if ((L2+W3) <=l1&& (W2&LT;=W1) && (L3&LT;=W1)) flag=true;    else if ((W2+L3) <=l1&& (L2&LT;=W1) && (W3&LT;=W1)) flag=true;    else if ((W2+W3) <=l1&& (L2&LT;=W1&AMP;&AMP;L3&LT;=W1)) flag=true;    else if ((W2+W3) <=w1&& (L2&LT;=L1) && (L3&LT;=L1)) flag=true;    else if ((W2+L3) <=w1&& (L2&LT;=L1) && (W3&LT;=L1)) flag=true;    else if ((L2+W3) <=w1&& (W2&LT;=L1) && (L3&LT;=L1)) flag=true;      else if ((L2+L3) <=w1&& (W2&LT;=L1) && (W3&LT;=L1)) flag=true;      if (flag) printf ("yes\n");    else printf ("no\n");  return 0;}



"Play CF, learn algorithm--Two star" Codeforces Round #313 (Div. 2) B. Gerald is into Art (water problem)

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.