B. Gerald is into Art
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的更多相关文章
- Gerald is into Art
Gerald is into Art Gerald bought two very rare paintings at the Sotheby's auction and he now wants t ...
- Codeforces Round #313 (Div. 2)B.B. Gerald is into Art
B. Gerald is into Art Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/ ...
- CodeForces 560B Gerald is into Art
Gerald is into Art time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #313 (Div. 2) B. Gerald is into Art 水题
B. Gerald is into Art Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/560 ...
- 【打CF,学算法——二星级】Codeforces Round #313 (Div. 2) B. Gerald is into Art(水题)
[CF简单介绍] 提交链接:http://codeforces.com/contest/560/problem/B 题面: B. Gerald is into Art time limit per t ...
- Codeforces Round #313 B. Gerald is into Art(简单题)
B. Gerald is into Art time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- 【45.65%】【codeforces 560B】Gerald is into Art
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- CodeForces 567A Gerald is into Art
http://codeforces.com/problemset/problem/567/A A. Lineland Mail time limit per test 3 seconds memory ...
- Codeforces Round #313 (Div. 2) A.B,C,D,E Currency System in Geraldion Gerald is into Art Gerald's Hexagon Equivalent Strings
A题,超级大水题,根据有没有1输出-1和1就行了.我沙茶,把%d写成了%n. B题,也水,两个矩形的长和宽分别加一下,剩下的两个取大的那个,看看是否框得下. C题,其实也很简单,题目保证了小三角形是正 ...
随机推荐
- Android LayoutInflator 解析
一.实际使用场景引入: 在ListView的Adapter的getView方法中基本都会出现,使用inflate方法去加载一个布局,用于ListView的每个Item的布局. 同样,在使用ViewP ...
- webpack 理解
目录 关于此文 在学习webpack之前,我们先去了解它的作用 它与其他其他前端工具(gulp,grunt)有什么差别呢 安装 webpack.config.js 配置结果 webpack 开始简单配 ...
- c#访问oracle数据库
想在c#中访问oracle数据库,毕竟是开发,想要轻量级访问oracle,客户机上无需安装oracle环境就能正常运行程序. 在网上找了相关资料,只需要引用一个dll即可实现. 访问代码(需引用dll ...
- Create 命令详解
mkdir:创建一个目录 /mkdir a b c :创建同级目录 /mkdir -p aa/bb/cc: 递归创建目录touch:修改文件时间戳,或者新建一个不存在的文件 /-a 更改存取时间 /m ...
- Java 包装类Integer的值比较
对于包装类型Integer的值比较与int的值比较是不同的: public class Java_Val_Compare { public static void main(String[] ar ...
- Chrome headless 模式
我们在通过Selenium运行自动化测试时,必须要启动浏览器,浏览器的启动与关闭必然会影响执行效率,而且还会干扰你做其它事情(本机运行的话). 那能不能把自动化测试的运行放在后台?当然可以! html ...
- 轻量级quill富文本编辑器
因为公司产品需要在移动端编辑文本,所以发现了这个轻量级的好东西,网上也没找到比较好的案例,就自己总结了下,有兴趣的直接复制代码运行看看就知道啦! 下面是quill.js的CDN加速地址: <!- ...
- 保存html上传文件过程中遇到的字节流和字符流问题总结
java字节流和字符流的区别以及相同 1. 字节流文件本身进行操作,字符流是通过缓存进行操作, 1.1 使用字节流不执行关闭操作 File f =new File("d:/test/test ...
- 如何将外部的obj模型导入OpenGL
1.关于obj的说明. obj中存放的是顶点坐标信息(v),面的信息(f),法线(vn),纹理坐标(vt),以及材质(这个放在mtl)中 我使用CINEMA 4D导出用VS查看后的信息: CINEMA ...
- Robot Framework学习笔记(八)------ride标签使用
一.edit标签使用 1.导入库 点击 Edit 标签页右侧的"Library"按钮,来添加库.在添加库之前,首先库已经在 Python 下进行了安装.如,添加"Sele ...