Codeforces Round #313 B. Gerald is into Art(简单题)
2 seconds
256 megabytes
standard input
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?
The first line contains two space-separated numbers a1 and b1 —
the sides of the board. Next two lines contain numbers a2, b2, a3 andb3 —
the sides of the paintings. All numbers ai, bi in
the input are integers and fit into the range from 1 to 1000.
If the paintings can be placed on the wall, print "YES" (without the quotes), and if they cannot, print "NO"
(without the quotes).
3 2
1 3
2 1
YES
5 5
3 3
3 3
NO
4 2
2 3
1 2
YES
That's how we can place the pictures in the first test:
And that's how we can do it in the third one.
题意:给出一个大的矩形,然后再给出两个小的矩形,问能不能把这两个小的矩
形在不重叠的情况下放进大的矩形中,能的话输出YES。否则输出NO
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h> using namespace std; int main()
{
int n,m;
while(scanf("%d%d",&n,&m)!=EOF)
{
int a,b;
int c,d;
scanf("%d%d",&a,&b);
scanf("%d%d",&c,&d);
if(((a+c)<=n &&max(b,d)<=m)||((a+c)<=m &&max(b,d)<=n) || ((a+d)<=n &&max(b,c)<=m) || ((a+d)<=m &&max(b,c)<=n) || ((b+d)<=n &&max(a,c)<=m)||((b+d)<=m &&max(a,c)<=n) || ((b+c)<=n &&max(a,d)<=m) || ((b+c)<=m &&max(a,d)<=n))
{
printf("YES\n");
}
else
{
printf("NO\n");
} }
return 0;
}
Codeforces Round #313 B. Gerald is into Art(简单题)的更多相关文章
- Codeforces Round #313 A. Currency System in Geraldion(简单题)
A. Currency System in Geraldion time limit per test 2 seconds memory limit per test 256 megabytes in ...
- Codeforces Round #313 C. Gerald's Hexagon(放三角形)
C. Gerald's Hexagon time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #519 by Botan Investments(前五题题解)
开个新号打打codeforces(以前那号玩废了),结果就遇到了这么难一套.touristD题用了map,被卡掉了(其实是对cf的评测机过分自信),G题没过, 700多行代码,码力惊人.关键是这次to ...
- 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 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 (Div. 2) A B C 思路 枚举 数学
A. Currency System in Geraldion time limit per test 2 seconds memory limit per test 256 megabytes in ...
- Codeforces Round #313 (Div. 2)(A,B,C,D)
A题: 题目地址:Currency System in Geraldion 题意:给出n中货币的面值(每种货币有无数张),要求不能表示出的货币的最小值.若全部面值的都能表示,输出-1. 思路:水题,就 ...
- Codeforces Round #313 (Div. 2) 解题报告
A. Currency System in Geraldion: 题意:有n中不同面额的纸币,问用这些纸币所不能加和到的值的最小值. 思路:显然假设这些纸币的最小钱为1的话,它就能够组成随意面额. 假 ...
随机推荐
- 打印出A到Z的所有字符,使用char和int转换
public class Demo14{ //A到Z的所有字符,使用char和int转换 public static void main(String[] args) { for(int i = 65 ...
- Myeclipse下载
地址:http://www.jb51.net/softs/593889.html#download
- Linux安装64位Mysql5.7.22
以安装在/usr/local目录下为例 1.下载安装包地址:https://dev.mysql.com/downloads/file/?id=476936,安装包保存到/usr/local 2.解压: ...
- javascript脚本的延时加载
javascript脚本的延时加载 向HTML页面中插入js代码的主要方法是使用<script>标签,在实际的开发中多采用外部文件的方式,主要考虑到外部js代码的可维护性及可缓存性等优点. ...
- ajax 传参数 数组 会加上中括号
解决办法 1,由于版本过高导致 我用的是1.9版本 2, 有三种选择. 一种是JSON.stringify([1,2,3]),到后端再解析. 另外一种是后端的接受的contentType改成appli ...
- 级数求和(C++)
题目描述 已知:Sn=1+1/2+1/3+…+1/n.显然对于任意一个整数K,当n足够大的时候,Sn大于K. 现给出一个整数K(1≤K≤15),要求计算出一个最小的n:使得Sn>K. 输入 ...
- Linux命令整理(2018/9/9-2018/9/15)
根据本周的Linux学习进度,整理了部分Linux知识及常用命令,待完善…… 1.显示默认启动方式(默认启动目标): systemctl get-default 2.设置默认启动方式(默认启动目标): ...
- 关于解决ssh的"Write failed: Broken pipe"问题
操作环境: 服务器:微软云 Linux CentOS 虚拟机 客户端:MAC OSX terminal 问题描述: 登录虚拟机短时间内不操作就会断开连接并报该“Write failed: Broken ...
- 【04】AJAX接收服务器返回的数据
AJAX接收服务器返回的数据 readyState 和 status 属性 readyState 属性保存有 XMLHttpRequest 对象的交互状态,从 0 到 4 变化: 0 :未初始化(还没 ...
- Python 循环语句(break和continue)
Python 循环语句(break和continue) while 语句时还有另外两个重要的命令 continue,break 来跳过循环,continue 用于跳过该次循环,break 则是用于退出 ...