Educational Codeforces Round 26:C. Two Seals

题目:

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.

题意:给出n张纸片的长和宽,再给出一个矩形的长和宽(a和b),求两张图片在矩形上放置的最大面积

思路:有两种情况 ,将第一张纸片横着放 or 竖着放,剩下的可以划分成3小块(再把其中相连的2块合成1块),判断第二张纸片能否不重叠地在放在矩形上。自己动手画个图就知道了。数据不打,暴力可过~

CODE:

#include<bits/stdc++.h>
using namespace std;
struct node
{
        int x,y;
}q[105];
int n,a,b;
int fun(){
        int i,j,x1,x2,x3,x4,y1,y2,y3,y4,maxr=0,flag;
        for(i=0;i<n;i++){
                x1=q[i].x;y1=q[i].y;   //纸片一
                for(j=i+1;j<n;j++){
                        flag=0;   //判断是否已选择一种方式存放
                        x2=q[j].x;y2=q[j].y;   //纸片二
                        if(x1<=a&&y1<=b){
                                x3=a-x1;y3=b;
                                x4=b-y1;y4=a;
                                if(x2<=x3&&y2<=y3||x2<=x4&&y2<=y4||x2<=y3&&y2<=x3||x2<=y4&&y2<=x4){
                                        maxr=max(maxr,x1*y1+x2*y2);
                                        flag=1;
                                }
                        }
                        if(!flag){
                                if(x1<=b&&y1<=a){
                                        x3=a-y1;y3=b;
                                        x4=b-x1;y4=a;
                                        if(x2<=x3&&y2<=y3||x2<=x4&&y2<=y4||x2<=y3&&y2<=x3||x2<=y4&&y2<=x4) maxr=max(maxr,x1*y1+x2*y2);
                                }
                        }
                }
        }
        return maxr;
}
int main()
{
        while(~scanf("%d%d%d",&n,&a,&b)){
                if(a>b) swap(a,b);
                for(int i=0;i<n;i++){
                        scanf("%d%d",&q[i].x,&q[i].y);
                        if(q[i].x>q[i].y) swap(q[i].x,q[i].y);
                }
                printf("%d\n",fun());
        }
        return 0;
}

根据提供的引用内容,Codeforces Round 511 (Div. 1)是一个比赛的名称。然而,引用内容中没有提供与这个比赛相关的具体信息或问。因此,我无法回答关于Codeforces Round 511 (Div. 1)的问。如果您有关于这个比赛的具体问,请提供更多的信息,我将尽力回答。 #### 引用[.reference_title] - *1* [Codeforces Round 860 (Div. 2)解](https://blog.csdn.net/qq_60653991/article/details/129802687)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Codeforces Round 867 (Div. 3)(A到E)](https://blog.csdn.net/wdgkd/article/details/130370975)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [Codeforces Round 872 (Div. 2)(前三道](https://blog.csdn.net/qq_68286180/article/details/130570952)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值