【打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 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 ana1?×?b1
rectangle, the paintings have shape of aa2?×?b2 anda3?×?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 andb1 — the sides of the board. Next two lines contain numbersa2,?b2,?a3
andb3 — the sides of the paintings. All numbersai,?bi in the
input are integers and fit into the range from1 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).

Sample test(s)

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 <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;
} 
时间: 2024-10-24 14:05:19

【打CF,学算法——二星级】Codeforces Round #313 (Div. 2) B. Gerald is into Art(水题)的相关文章

Codeforces Round #313 (Div. 2) C Gerald&#39;s Hexagon 计数

// Codeforces Round #313 (Div. 2) C Gerald's Hexagon // 计数 // 关键是平行于a1的长度为1的有多少条,中间的这些*2,再加上a1 // 和a4,就是三角形的总和 // 还是挺简单的,注意递增的初始值,和变化,就ac了 #include <cstdio> #include <algorithm> #include <iostream> #include <cstring> using namespac

Codeforces Round #313 (Div. 1) C. Gerald and Giant Chess

这场CF又掉分了... 这题题意大概就给一个h*w的棋盘,中间有一些黑格子不能走,问只能向右或者向下走的情况下,从左上到右下有多少种方案. 开个sum数组,sum[i]表示走到第i个黑点但是不经过其他黑点的方案数. 式子是sum[i]=c(x[i]+y[i],x[i])-Σ(sum[j]*c(x[i]-x[j]+y[i]-y[j],x[i]-x[j])). c(x+y,x)表示从格子(1,1)到(x,y)的方案数(没有黑点). 因此每个点按x[i]+y[i]的值排个序,然后n^2弄一下他们的拓扑

Codeforces Round #313 (Div. 2) Gerald&#39;s Hexagon

给出一个六边形六条边的长度(六边形的每个角为120度),求出这个六边形中边长为1的等边三角形有多少个 由于每个角都是120度并且上下两条边是平行的,因此我们可以补出一个矩形,再减掉周边四个角的面积,用剩下面积除以每个小三角形的面积. #include<cstdio> using namespace std; double a,b,c,d,e,f; int main() { <span style="white-space:pre"> </span>s

Codeforces Round #313 (Div. 1)

官方英文题解:http://codeforces.com/blog/entry/19237 Problem A: 题目大意: 给出内角和均为120°的六边形的六条边长(均为正整数),求最多能划分成多少个边长为1的正三角形. 题解: 把六边形补全变成一个正三角形,然后减去三个角的正三角形即可. Problem B: 题目大意: 给出长度相等的两个串AB,定义两个串相等 当且仅当  A=B  或者  当长度为偶数时,A[1...n/2]=B[1...n/2]  && A[n/2+1...n]=

Codeforces Round #258 (Div. 2) B. Sort the Array(简单题)

题目链接:http://codeforces.com/contest/451/problem/B ---------------------------------------------------------------------------------------------------------------------------------------------------------- 欢迎光临天资小屋:http://user.qzone.qq.com/593830943/ma

【cf比赛记录】Codeforces Round #600 (Div. 2)

Codeforces Round #600 (Div. 2) ---- 比赛传送门 昨晚成绩还好,AC A,B题,还能上分(到底有多菜) 补了C.D题,因为昨晚对C.D题已经有想法了,所以补起题来也快.(C题TLE了,D题想用并查集没好) A // http://codeforces.com/contest/1253/problem/A /* 如果YES,则b[i] - a[i] 在一个区间里的差肯定是相同的且不小于0 */ #include<iostream> #include<cst

Codeforces Round #313 (Div. 2) (ABCD题解)

比赛链接:http://codeforces.com/contest/560 水笔场... A. Currency System in Geraldion time limit per test:2 seconds memory limit per test:256 megabytes A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several va

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/problem/560/B Description 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

【打CF,学算法——一星级】Codeforces Round #313 (Div. 2) A. Currency System in Geraldion

[CF简单介绍] 提交链接:http://codeforces.com/contest/560/problem/A 题面: A. Currency System in Geraldion time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A magic island Geraldion, where Gerald lives,