zoukankan      html  css  js  c++  java
  • Codefroces Educational Round 26 837 C. Two Seals

    C. Two Seals
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    One very important person has a piece of paper in the form of a rectangle a × b.

    Also, he has n seals. Each seal leaves an impression on the paper in the form of a rectangle of the size xi × yi. Each impression must be parallel to the sides of the piece of paper (but seal can be rotated by 90 degrees).

    A very important person wants to choose two different seals and put them two impressions. Each of the selected seals puts exactly one impression. Impressions should not overlap (but they can touch sides), and the total area occupied by them should be the largest possible. What is the largest area that can be occupied by two seals?

    Input

    The first line contains three integer numbers n, a and b (1 ≤ n, a, b ≤ 100).

    Each of the next n lines contain two numbers xi, yi (1 ≤ xi, yi ≤ 100).

    Output

    Print the largest total area that can be occupied by two seals. If you can not select two seals, print 0.

    Examples
    Input
    2 2 2
    1 2
    2 1
    Output
    4
    Input
    4 10 9
    2 3
    1 1
    5 10
    9 11
    Output
    56
    Input
    3 10 10
    6 6
    7 7
    20 5
    Output
    0
    Note

    In the first example you can rotate the second seal by 90 degrees. Then put impression of it right under the impression of the first seal. This will occupy all the piece of paper.

    In the second example you can't choose the last seal because it doesn't fit. By choosing the first and the third seals you occupy the largest area.

    In the third example there is no such pair of seals that they both can fit on a piece of paper.

     一个大矩形内放两个矩形印章,暴力吧!

    
    
    #include <iostream> 
    #include <algorithm> 
    #include <cstring> 
    #include <cstdio>
    #include <vector> 
    #include <queue> 
    #include <cstdlib> 
    #include <iomanip>
    #include <cmath> 
    #include <ctime> 
    #include <map> 
    #include <set> 
    using namespace std; 
    #define lowbit(x) (x&(-x)) 
    #define max(x,y) (x>y?x:y) 
    #define min(x,y) (x<y?x:y) 
    #define MAX 100000000000000000 
    #define MOD 1000000007
    #define pi acos(-1.0) 
    #define ei exp(1) 
    #define PI 3.141592653589793238462
    #define ios() ios::sync_with_stdio(false)
    #define INF 0x3f3f3f3f 
    #define mem(a) (memset(a,0,sizeof(a))) 
    typedef long long ll;
    int n,m,k,x[110],y[110],ans;
    int get(int x,int y,int a,int b)
    {
        if((x+a>n || y>m || b>m) && (y+b>m || x>n || a>n)) return 0;
        return x*y+a*b;
    }
    int main()
    {
        scanf("%d%d%d",&k,&n,&m);
        ans=0;
        for(int i=0;i<k;i++) scanf("%d%d",&x[i],&y[i]);
        for(int i=0;i<k;i++)
        {
            for(int j=i+1;j<k;j++)
            {
                ans=max(ans,max(max(get(x[i],y[i],x[j],y[j]),get(y[i],x[i],x[j],y[j])),max(get(x[i],y[i],y[j],x[j]),get(y[i],x[i],y[j],x[j]))));
            }
        }
        printf("%d
    ",ans);
        return 0;
    }
    
    
    
    
    
  • 相关阅读:
    看过的代码
    ScipyLectures-simple学习笔记
    机器学习1一个月2017/11/24-2017/12/24
    机器学习课程 matlab 练习
    win7 win8 快捷键直接调出任务管理器
    java 关于getProperty()方法中反斜杠问题
    把myeclipse中html/jsp文件的视图调到只看代码
    Win7 server2008 共享文件夹 不输入网络密码
    别用visual editor了,用WindowBuilder
    visual editor ve1.5下载
  • 原文地址:https://www.cnblogs.com/shinianhuanniyijuhaojiubujian/p/7284119.html
Copyright © 2011-2022 走看看