B. Gerald is into Art

时间:2022-11-13 15:48:12

B. Gerald is into Art

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard 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.

两个矩形能否不重叠的放入第三个矩形中、暴力枚举

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <map>
using namespace std; typedef long long int llint;
#define ite ::iterator
#define mem(a) memset(a, 0, sizeof(a))
#define pi acos(-1)
const llint maxn = 2e5+100;
/*-------------------模板-----------------------------------------*/
template <typename T>
int com(const T& v1, const T& v2) {
if (v1 < v2) return -1;
else if (v1 > v2) return 1;
return 0;
} int a[1100][1100]; int main() {
mem(a);
//freopen("text.in", "r", stdin);
//freopen("text.out", "w", stdout);
int a1, b1, a2, b2, a3, b3;
cin >> a1 >> b1 >> a2 >> b2 >> a3 >> b3;
int flag = 0;
int a11 = max(a1, b1), b11 = min(a1, b1);
int a22 = max(a2, b2), b22 = min(a2, b2);
//int a33 = max(a3, b3), b33 = min(a3, b3);
int n1 = a11 - a22, n2 = b11 - b22;
if (n1 >= 0 && n2 >= 0) {
if ((n1>=a3 && b11>=b3) || (n1>=b3 && b11>=a3)) flag = 1;
if ((n2>=a3 && a11>=b3) || (n2>=b3 && a11>=a3)) flag = 1;
}
n1 = a11 - b22, n2 = b11 - a22;
if (n1 >= 0 && n2 >= 0) {
if ((n1>=a3 && b11>=b3) || (n1>=b3 && b11>=a3)) flag = 1;
if ((n2>=a3 && a11>=b3) || (n2>=b3 && a11>=a3)) flag = 1;
}
if (flag) cout << "YES" << endl;
else cout << "NO" << endl;
return 0;
}

B. Gerald is into Art的更多相关文章

  1. Gerald is into Art

    Gerald is into Art Gerald bought two very rare paintings at the Sotheby's auction and he now wants t ...

  2. Codeforces Round &num;313 &lpar;Div&period; 2&rpar;B&period;B&period; Gerald is into Art

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

  3. CodeForces 560B Gerald is into Art

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

  4. Codeforces Round &num;313 &lpar;Div&period; 2&rpar; B&period; Gerald is into Art 水题

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

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

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

  6. Codeforces Round &num;313 B&period; 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&period;65&percnt;】【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 &num;313 &lpar;Div&period; 2&rpar; A&period;B&comma;C&comma;D&comma;E Currency System in Geraldion &Tab; Gerald is into Art Gerald&&num;39&semi;s Hexagon Equivalent Strings

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

随机推荐

  1. 详解mmseg

    本文先介绍下mmseg的概念和算法,再说下mmseg4j-solor的3个分词器用法 1.mmseg概念 mmseg是用于中文切词的算法,即Maximum Matching Segment,最大匹配分 ...

  2. php加密解密

    <?php . [代码][PHP]代码      <?php , ;         return setcookie($name, $value, $expire, $path, $do ...

  3. js 监听监键盘动作(转)

    主要分四个部分 第一部分:浏览器的按键事件 第二部分:兼容浏览器 第三部分:代码实现和优化 第四部分:总结 第一部分:浏览器的按键事件 用js实现键盘记录,要关注浏览器的三种按键事件类型,即keydo ...

  4. Linux单词表

     su:Swith user  切换用户,切换到root用户cat: Concatenate  串联uname: Unix name  系统名称df: Disk free  空余硬盘du: Disk  ...

  5. js中定义对象的方式有哪些?

    1.对象直接量 2.构造函数 3.原型方法 4.动态原型方法

  6. 翻页采用jaxa

    <!-- 翻页采用jaxa --><script type="text/javascript">//class="page"下面的a被点 ...

  7. springMVC中得到request对象,session对象

    RequestAttributes ra = RequestContextHolder.getRequestAttributes(); HttpServletRequest request = ((S ...

  8. js实现购买数量加减效果

    写在前面:当我们需要在多个页面都有操作数量的需求时的一种解决方案 结构: js代码: <script type="text/javascript"> function ...

  9. Python开发——函数【装饰器、高阶函数、函数嵌套、闭包】

    装饰器 装饰器本质就是函数,为其他函数添加附加功能. 原则: 不修改被修饰函数的源代码 不修改被修饰函数的调用方法 装饰器知识储备:装饰器 = 高阶函数 + 函数嵌套 + 闭包 案例:求函数运行时间! ...

  10. 我对android开发的一点小感悟小看法

    “Android”,“Android开发”等等这些词成了时下最热的词,也是时下大众最关注最吸引人眼球的话题,当然,最热门的行业也意味着高薪,好的就业环境,但同时也意味着强大的竞争力! Android系 ...