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 na and b (1 ≤ n, a, b ≤ 100).

Each of the next n lines contain two numbers xiyi (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 21 22 1

output
4

input
4 10 92 31 15 109 11

output
56

input
3 10 106 67 720 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

 1 #include <iostream>
 2 #include <stdio.h>
 3 using namespace std;
 4 int n, a, b;
 5 int x[120];
 6 int y[120];
 7
 8 int main(){
 9     int ans=0;
10     cin>>n>>a>>b;
11     for(int i=0;i<n;i++)
12         cin>>x[i]>>y[i];
13     for(int i=0;i<n;i++){
14         for(int j=i+1;j<n;j++){
15             for(int it1=0;it1<2;it1++,swap(x[i],y[i])){
16                 for(int it2=0;it2<2;it2++,swap(x[j],y[j])){
17                     if(x[i]+x[j]<=a&&max(y[i],y[j])<=b)
18                         ans=max(x[i]*y[i]+x[j]*y[j],ans);
19                     if(x[i]+x[j]<=b&&max(y[i],y[j])<=a)
20                         ans=max(x[i]*y[i]+x[j]*y[j],ans);
21                 }
22             }
23         }
24     }
25     cout<<ans<<"\n";
26     return 0;
27 }

转载于:https://www.cnblogs.com/z-712/p/7295599.html

Educational Round 26 C. Two Seals相关推荐

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

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

  2. Codeforces Educational Round 5

    Codeforces Educational Round 5 通过数: 4 Standing: 196/4176 题目链接: http://codeforces.com/contest/616 A: ...

  3. educational round 前缀和_总结分析634个以re为前缀的单词得出了re为前缀组合单词意思规律

    学英语需要有耐心.恒心!本文稍长!本文的目的所在是让读者在一篇文章里可以理解634个re前缀的单词,更重要的是可以复习到对应的634个常见的基础单词. 看下面的动图,小球从高点回到底部,从底部回到高点 ...

  4. CodeForces616:Educational Round 5

    文章目录 前言 A Comparing Two Long Integers\text{A Comparing Two Long Integers}A Comparing Two Long Intege ...

  5. Educational Round 66 题解

    作为橙名来水了一发-- 这次题目就比上次良心多了.7题有5题会做. 然而风格仍然很怪异--还是练少了? A 水题.不过一开始没注意细节挂了几发,罚时罚的真痛-- 明显是能除以 $k$ 就除以 $k$, ...

  6. Codeforces Educational round 58

    Ediv2 58 随手AK.jpg D 裸的虚树,在这里就不写了 E 傻逼贪心?这个题过的比$B$都多.jpg #include <cstdio> #include <algorit ...

  7. CF Educational Round 23 F.MEX Queries

    写了3小时 = =.这两天堕落了,昨天也刷了一晚上hihocoder比赛,还爆了零.之后得节制点了,好好准备考研.. 首先很容易想到 压缩数据 + 线段树 然后对于Pushdown真很难写..需要牵涉 ...

  8. Educational Round 64 题解

    前言: 这场太难了--我一个紫名只打出两题--(虽说感觉的确发挥不够好) 一群蓝绿名的dalao好像只打了两题都能升分的样子-- 庆幸的是最后A出锅然后unr了>///< 写一波题解纪念这 ...

  9. [BC Round#26] Card 【各种水】

    题目链接:HDOJ - 5159 这道题的做法太多了..BC的第二题也是可以非常水的.. 算法一 我在比赛的时候写的算法是这样的.. 预处理出所有的答案,然后对于每个询问直接输出. 询问 (a, b) ...

最新文章

  1. 聚类--K均值算法:自主实现与sklearn.cluster.KMeans调用
  2. https和server-status配置案例
  3. java计算时间差_JAVA并发编程三大Bug源头(可见性、原子性、有序性),彻底弄懂...
  4. 【VMCloud云平台】SCOM配置(四)-监控应用可用性
  5. 【带着canvas去流浪】 (3)绘制饼图
  6. [译] REST API 已死,GraphQL 长存
  7. winform耗时代码处理,仿win10加载动画Loading(等待界面)
  8. adb小天才_ADB工具包2020年最新版下载-支持解锁新机BL调试ROOT等各种操作
  9. 前端之路--第三周学习
  10. 爬取网站小猪短租的少量信息及详细介绍 ,requests库,bs4库的使用
  11. 静态网页制作初步体会
  12. Java必突-JVM知识专题(一): Java代码是如何跑起来的+类加载到使用的过程+类从加载到使用核心阶段(类初始化)+类加载的层级结构+什么是JVM的内存区域划分?Java虚拟机栈、Java堆内存
  13. 《拥抱变化——社交网络时代的企业转型之道》一第1章 助力社交商务成功的AGENDA体系...
  14. 基于golang的爬虫demo,爬取微博用户的粉丝和关注者信息
  15. 高性能Java代码的最佳实践
  16. mysql经典四表查询_sql 经典四表查询
  17. java+springboot的大学生心理健康测试测评系统vue
  18. 当CollapsingToolbarLayout与ToolBar如何设置Title居中
  19. matlab 矩阵转置,列、行翻转
  20. linux在没网的情况下安装libreoffice

热门文章

  1. LeetCode 1035 不相交的线
  2. 在PTA中c语言中求连续因子,团体程序设计天梯赛-练习集L1-006. *连续因子
  3. java如何设置文本框提示_[Java教程]一个友好的文本框内显示提示语 jquery 插件
  4. 用pcl读ply文件_一分钟详解PCL中点云配准技术
  5. java中的变量是原子的_Java原子变量
  6. wgan 不理解 损失函数_GAN:「太难的部分我就不生成了,在下告退」
  7. 浏览器管理oracle网址,浏览器用户界面 (Browser User Interface, BUI)
  8. 配置多个ssh-key
  9. github fork别人项目后如何同步更新原项目
  10. Windows下启动Apache报错:ServerRoot must be a valid directory