Coderforce 560B-Gerald is into Art

题目大意:给了三个矩形的长和宽,问第一个能否把其他两个装在内部,要求内部之间不重叠,不出界(可重边)?

题目分析:这道题。。。考虑不够全面导致比赛时没有出来。。。当时,就是觉得自己的代码很完美,不可能不对!当时也是较起真儿来啦,全场就我一个人没A这道题,确实有点脑子热!以后再遇到这种情况一定要冷静!要沉着!越急越没用!!!要重新审视自己的算法和代码!!!!!

代码如下:

# include<iostream>
# include<cstdio>
# include<cmath>
# include<string>
# include<vector>
# include<list>
# include<set>
# include<map>
# include<queue>
# include<cstring>
# include<algorithm>
using namespace std;

# define LL long long
# define REP(i,s,n) for(int i=s;i<n;++i)
# define CL(a,b) memset(a,b,sizeof(a))
# define CLL(a,b,n) fill(a,a+n,b)

const double inf=1e30;
const int INF=1<<30;
const int N=1000;

int a1,b1,a2,b2,a3,b3;

bool ok(int a,int b)
{
    if(a>=a3&&b>=b3) return true;
    if(a>=b3&&b>=a3) return true;
    return false;
}

bool judge()
{
    if(a1*b1<a2*b2+a3*b3) return false;///
    if(a1<b1) swap(a1,b1);///
    if(a2<b2) swap(a2,b2);///
    if(a3<b3) swap(a3,b3);///
    if(b2>a1||a2>a1) return false;///
    if(b3>a1||a3>a1) return false;///
    if(b2+b3>a1) return false;///比赛的时候以上这些都没写,一直过不去
    if(ok(b1,a1-a2)) return true;
    if(ok(b1,a1-b2)) return true;
    if(ok(a1,b1-a2)) return true;
    if(ok(a1,b1-b2)) return true;
    return false;
}

int main()
{
    while(~scanf("%d%d%d%d%d%d",&a1,&b1,&a2,&b2,&a3,&b3))
    {
        if(judge()) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

  

时间: 2024-10-10 10:07:08

Coderforce 560B-Gerald is into Art的相关文章

Codeforces 560B 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

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) 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 a

Gerald is into Art

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, t

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)

A. Currency System in Geraldion 刚开始以为是什么动态规划,直接在那里叫这可怎么办?后来又想到如果10里面的数可以拼出来,那么大的也可以拼出来了,于是这样写就过了.今天早上一看人家的代码,才发现如果一可以拼出来,那么其他都可以拼出来.所以只需要将输入的数排序,第一个是不是一考虑一下就可以了.自己思维还是不够. #include<bits/stdc++.h> using namespace std; int a[1024],dp[1000000+5]; int ma

Codeforces Round #313 (Div. 2) 解题报告

A. Currency System in Geraldion: 题意:有n中不同面额的纸币,问用这些纸币所不能加和到的值的最小值. 思路:显然假设这些纸币的最小钱为1的话,它就能够组成随意面额. 假设这些纸币的最小值大于1,那么它所不能组成的最小面额就是1.所以自学求最小值就可以. 我的代码: #include <set> #include <map> #include <cmath> #include <stack> #include <queue

Codeforces Round #313 (Div. 2)(A,B,C,D)

A题: 题目地址:Currency System in Geraldion 题意:给出n中货币的面值(每种货币有无数张),要求不能表示出的货币的最小值,若所有面值的都能表示,输出-1. 思路:水题,就是看看有没有面值为1的货币,如果有的话,所有面值的货币都可以通过1的累加得到,如果没有的话,最小的不能表示的就当然是1辣. #include <stdio.h> #include <math.h> #include <string.h> #include <stdli

chd校内选拔赛题目+题解

题目链接   A. Currency System in Geraldion 有1时,所有大于等于1的数都可由1组成.没有1时,最小不幸的数就是1. 1 #include<iostream> 2 #include<cstdio> 3 #include<algorithm> 4 using namespace std; 5 void solve(){ 6 int n,x; 7 scanf("%d",&n); 8 int flag = 0; 9