time limit per test2 seconds

memory limit per test256 megabytes

inputstandard input

outputstandard output

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 and b3 — 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).

Examples

input

3 2

1 3

2 1

output

YES

input

5 5

3 3

3 3

output

NO

input

4 2

2 3

1 2

output

YES

Note

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

And that’s how we can do it in the third one.

【题目链接】:http://codeforces.com/contest/560/problem/B

【题解】



先固定第一个矩形在左下角(靠边);这样肯定是最好的方法;

然后枚举第二个矩形要放在哪里;

两个矩形都有两种形态.即竖着放还是横着放;

处理一下就好;

时间复杂度是O(N^2);

->第二个矩形只有判断有没有越界就可以了;



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%I64d",&x) typedef pair<int,int> pii;
typedef pair<LL,LL> pll; const int MAXN = 1e3+100;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0); int n,x;
int a1,b1,a2,b2,a3,b3;
bool bo[MAXN][MAXN]; bool get_ans()
{
rep1(i,1,a1)
rep1(j,1,b1)
if (bo[i][j])
{
if (i+a3-1<=a1 && j+b3-1<=b1) return true;
if (i+b3-1<=a1 && j+a3-1<=b1) return true;
// if (get_ans1(i,j,a3,b3)) return true;
// if (get_ans1(i,j,b3,a3)) return true;
}
return false;
} bool chushi(int ta,int tb)
{
memset(bo,false,sizeof bo);
rep1(i,1,a1)
rep1(j,1,b1)
bo[i][j] = true;
rep1(i,1,ta)
rep1(j,1,tb)
if (!bo[i][j])
return false;
else
bo[i][j] = false;
return true;
} int main()
{
//freopen("F:\\rush.txt","r",stdin);
rei(a1);rei(b1);
rei(a2);rei(b2);
rei(a3);rei(b3);
if (chushi(a2,b2))
if (get_ans())
{
puts("YES");
return 0;
}
if (chushi(b2,a2))
if (get_ans())
{
puts("YES");
return 0;
}
puts("NO");
return 0;
}

【45.65%】【codeforces 560B】Gerald is into Art的更多相关文章

  1. 【 BowWow and the Timetable CodeForces - 1204A 】【思维】

    题目链接 可以发现 十进制4 对应 二进制100 十进制16 对应 二进制10000 十进制64 对应 二进制1000000 可以发现每多两个零,4的次幂就增加1. 用string读入题目给定的二进制 ...

  2. 【codeforces 734F】Anton and School

    [题目链接]:http://codeforces.com/problemset/problem/734/F [题意] 给你两个数组b和c; 然后让你找出一个非负数组a满足题中所给关系; [题解] 有个 ...

  3. 【codeforces 65A】Harry Potter and Three Spells

    [题目链接]:http://codeforces.com/problemset/problem/65/A [题意] 你有3种魔法; 1.可以将a单位的石头变成b单位的铅 2.可以将c单位的铅变成d单位 ...

  4. 【codeforces 750D】New Year and Fireworks

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

  5. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  6. 【搜索】【并查集】Codeforces 691D Swaps in Permutation

    题目链接: http://codeforces.com/problemset/problem/691/D 题目大意: 给一个1到N的排列,M个操作(1<=N,M<=106),每个操作可以交 ...

  7. 【中途相遇法】【STL】BAPC2014 K Key to Knowledge (Codeforces GYM 100526)

    题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...

  8. 【链表】【模拟】Codeforces 706E Working routine

    题目链接: http://codeforces.com/problemset/problem/706/E 题目大意: 给一个N*M的矩阵,Q个操作,每次把两个同样大小的子矩阵交换,子矩阵左上角坐标分别 ...

  9. 【数论】【扩展欧几里得】Codeforces 710D Two Arithmetic Progressions

    题目链接: http://codeforces.com/problemset/problem/710/D 题目大意: 两个等差数列a1x+b1和a2x+b2,求L到R区间内重叠的点有几个. 0 < ...

随机推荐

  1. worktools-git 工具的使用总结(2)

    1.创建分支 git branch son parent //创建分支,是在master 分支的基础上创建 :~/myGit$ git st # On branch master nothing to ...

  2. php中类文件名的命名的规则是什么

    php中类文件名的命名的规则是什么 一.总结 一句话总结:类库文件(工具类)类文件都是以.class.php为后缀. 1.类的方法和属性的命名规则是怎样的? 都是小驼峰法 方法的命名使用驼峰法,并且首 ...

  3. [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) 问题解决

    问题描述详情: 无论你的问题是3.0还是3.1还是任何一个版本,则都可以通过以下版本来解决 解决办法: 把默认的Internal JRE改成了JAVA_HOME. 运行后成功了,截图如下:

  4. HDU 3864 D_num Miller Rabin 质数推断+Pollard Rho大整数分解

    链接:http://acm.hdu.edu.cn/showproblem.php? pid=3864 题意:给出一个数N(1<=N<10^18).假设N仅仅有四个约数.就输出除1外的三个约 ...

  5. 非极大值抑制(non-maximum suppression)的理解与实现

    非极大抑制(Non-Maximum Suppression) Non-Maximum Suppression for Object Detection in Python RCNN 和微软提出的 SP ...

  6. 【CS Round #44 (Div. 2 only) D】Count Squares

    [链接]点击打开链接 [题意] 给你一个0..n和0..m的区域. 你可以选定其中的4个点,然后组成一个正方形. 问你可以圈出多少个正方形. (正方形的边不一定和坐标轴平行) [题解] 首先,考虑只和 ...

  7. 在Windows下搭建Apacheserver

    Apacheserver是一款基于HTTP协议的webserver.Apacheserver使用CGI开发 首先下载Apacheserver,下载地址http://download.csdn.net/ ...

  8. JS错误记录 - 取消事件冒泡、按钮、回车、ctrl回车提交留言

    window.onload = function () { var oDiv = document.getElementById('div1'); var oBtn = document.getEle ...

  9. JMeter--聚合报告之 90% Line 正确理解

    90% Line 参数正确的含义: 虽然,我的上面理解有一定的道理,显然它(90% 用户的响应时间)是错误的.那看看JMeter 官网是怎么说的? 90% Line - 90% of the samp ...

  10. [React Intl] Format Numbers with Separators and Currency Symbols using react-intl FormattedNumber

    Using a react-intl FormattedNumber component, we'll pass a Number and a few additional props in orde ...