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[],y[],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 ;
return x*y+a*b;
}
int main()
{
scanf("%d%d%d",&k,&n,&m);
ans=;
for(int i=;i<k;i++) scanf("%d%d",&x[i],&y[i]);
for(int i=;i<k;i++)
{
for(int j=i+;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\n",ans);
return ;
}


Codefroces Educational Round 26 837 C. Two Seals的更多相关文章

  1. Codefroces Educational Round 26 837 D. Round Subset

    D. Round Subset time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  2. Codefroces Educational Round 26 837 B. Flag of Berland

    B. Flag of Berland time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  3. Codefroces Educational Round 27 845G Shortest Path Problem?

    Shortest Path Problem? You are given an undirected graph with weighted edges. The length of some pat ...

  4. Codefroces Educational Round 27 (A,B,C,D)

    A. Chess Tourney time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  5. Educational Codeforces Round 26

    Educational Codeforces Round 26 困到不行的场,等着中午显示器到了就可以美滋滋了 A. Text Volume time limit per test 1 second ...

  6. CodeForces 837F - Prefix Sums | Educational Codeforces Round 26

    按tutorial打的我血崩,死活挂第四组- - 思路来自FXXL /* CodeForces 837F - Prefix Sums [ 二分,组合数 ] | Educational Codeforc ...

  7. CodeForces - 837E - Vasya's Function | Educational Codeforces Round 26

    /* CodeForces - 837E - Vasya's Function [ 数论 ] | Educational Codeforces Round 26 题意: f(a, 0) = 0; f( ...

  8. CodeForces 837D - Round Subset | Educational Codeforces Round 26

    /* CodeForces 837D - Round Subset [ DP ] | Educational Codeforces Round 26 题意: 选k个数相乘让末尾0最多 分析: 第i个数 ...

  9. [Educational Round 5][Codeforces 616F. Expensive Strings]

    这题调得我心疲力竭...Educational Round 5就过一段时间再发了_(:з」∠)_ 先后找了三份AC代码对拍,结果有两份都会在某些数据上出点问题...这场的数据有点水啊_(:з」∠)_[ ...

随机推荐

  1. 20180929 北京大学 人工智能实践:Tensorflow笔记05

    (完)

  2. caioj 1084 动态规划入门(非常规DP8:任务安排)(取消后效性)

    这道题的难点在于,前面分组的时间会影响到后面的结果 也就是有后效性,这样是不能用dp的 所以我们要想办法取消后效性 那么,我们就可以把影响加上去,也就是当前这一组加上了s 那么就把s对后面的影响全部加 ...

  3. 紫书 习题 10-9 UVa 294(正约数个数)

    一个数的正约数个数等于这个数的质因数分解后 每一项幂+1的积 因为每个质因数的幂可以为0, 1, 2--(注意可以为0) 所以就每个质因数配一个幂任意组合就可得一个正因数,根据乘法原理可得正约数个数. ...

  4. docker容器存放目录磁盘空间满了,转移数据修改Docker默认存储位置

    原文:docker容器存放目录磁盘空间满了,转移数据修改Docker默认存储位置 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/qq_3767485 ...

  5. SPOJ 694 Distinct Substrings

    Distinct Substrings Time Limit: 1000ms Memory Limit: 262144KB This problem will be judged on SPOJ. O ...

  6. Oracle运行set autotrace on报错SP2-0618、SP2-0611

    SQL> set autotrace on SP2-0618: 无法找到会话标识符.启用检查 PLUSTRACE 角色 SP2-0611: 启用 STATISTICS 报告时出错 原因: PLU ...

  7. ArcGIS api for javascript——1,2,3综合

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"% ...

  8. Hadoop RPC框架

    1.RPC框架概述 1.1 RPC(Remote Procedure Call Protocol)--远程过程调用协议,它是一种通过网络从远程计算机程序上请求服务,而不须要了解底层网络技术的协议. R ...

  9. Ubuntu常见报错及解决方式汇总

    作者:郭孝星 微博:郭孝星的新浪微博 邮箱:allenwells@163.com 博客:http://blog.csdn.net/allenwells Github:https://github.co ...

  10. modSecurity规则学习(七)——防止SQL注入

    1.数字型SQL注入 /opt/waf/owasp-modsecurity-crs/rules/REQUEST-942-APPLICATION-ATTACK-SQLI.conf"] [lin ...