"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", &L1,&W1); scanf ("%d%d", &L2,&W2); scanf ("%d%d", &L3,&W3); BOOL Flag=false; if ((L2+L3) <=l1&& (W2<=W1&&W3<=W1)) flag=true; else if ((L2+W3) <=l1&& (W2<=W1) && (L3<=W1)) flag=true; else if ((W2+L3) <=l1&& (L2<=W1) && (W3<=W1)) flag=true; else if ((W2+W3) <=l1&& (L2<=W1&&L3<=W1)) flag=true; else if ((W2+W3) <=w1&& (L2<=L1) && (L3<=L1)) flag=true; else if ((W2+L3) <=w1&& (L2<=L1) && (W3<=L1)) flag=true; else if ((L2+W3) <=w1&& (W2<=L1) && (L3<=L1)) flag=true; else if ((L2+L3) <=w1&& (W2<=L1) && (W3<=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)