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 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 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.

题意:每个印章只能用一次,问能否盖两个印章。如果能,找出最大面积,不能输出0.

思路:暴力枚举。

ps:开始用了排序,后来发现sort写的有问题。直接暴力就AC了。

 1 #include<iostream>
2 #include<stdio.h>
3 #include<algorithm>
4 using namespace std;
5 struct Node{
6 int x,y,s;
7 }an[105];
8 int main(){
9 int n,a,b;
10 cin>>n>>a>>b;
11 for(int i=0;i<n;i++){
12 scanf("%d %d",&an[i].x,&an[i].y);
13 an[i].s=an[i].x*an[i].y;
14 }
15 int mx=0;
16 for(int i=0;i<n-1;i++){
17 for(int j=i+1;j<n;j++){
18 if(an[i].x+an[j].x<=a&&an[i].y<=b&&an[j].y<=b&&an[i].s+an[j].s<=a*b){
19 mx=max(mx,an[i].s+an[j].s);
20 }else if(an[i].x+an[j].y<=a&&an[i].y<=b&&an[j].x<=b&&an[i].s+an[j].s<=a*b){
21 mx=max(mx,an[i].s+an[j].s);
22 }else if(an[i].y+an[j].x<=a&&an[i].x<=b&&an[j].y<=b&&an[i].s+an[j].s<=a*b){
23 mx=max(mx,an[i].s+an[j].s);
24 }else if(an[i].y+an[j].y<=a&&an[i].x<=b&&an[j].x<=b&&an[i].s+an[j].s<=a*b){
25 mx=max(mx,an[i].s+an[j].s);
26 }else if(an[i].x+an[j].x<=b&&an[i].y<=a&&an[j].y<=a&&an[i].s+an[j].s<=a*b){
27 mx=max(mx,an[i].s+an[j].s);
28 }else if(an[i].x+an[j].y<=b&&an[i].y<=a&&an[j].x<=a&&an[i].s+an[j].s<=a*b){
29 mx=max(mx,an[i].s+an[j].s);
30 }else if(an[i].y+an[j].x<=b&&an[i].x<=a&&an[j].y<=a&&an[i].s+an[j].s<=a*b){
31 mx=max(mx,an[i].s+an[j].s);
32 }else if(an[i].y+an[j].y<=b&&an[i].x<=a&&an[j].x<=a&&an[i].s+an[j].s<=a*b){
33 mx=max(mx,an[i].s+an[j].s);
34 }else{}
35 }
36 }
37 cout<<mx<<endl;
38 return 0;
39 }

Educational Codeforces Round 26 Problem C的更多相关文章

  1. Educational Codeforces Round 26

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

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

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

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

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

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

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

  5. Educational Codeforces Round 32 Problem 888C - K-Dominant Character

    1) Link to the problem: http://codeforces.com/contest/888/problem/C 2) Description: You are given a ...

  6. Educational Codeforces Round 26 [ D. Round Subset ] [ E. Vasya's Function ] [ F. Prefix Sums ]

    PROBLEM D - Round Subset 题 OvO http://codeforces.com/contest/837/problem/D 837D 解 DP, dp[i][j]代表已经选择 ...

  7. Educational Codeforces Round 26 B,C

    B. Flag of Berland 链接:http://codeforces.com/contest/837/problem/B 思路:题目要求判断三个字母是否是条纹型的,而且宽和高相同,那么先求出 ...

  8. Educational Codeforces Round 21 Problem E(Codeforces 808E) - 动态规划 - 贪心

    After several latest reforms many tourists are planning to visit Berland, and Berland people underst ...

  9. Educational Codeforces Round 21 Problem D(Codeforces 808D)

    Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into t ...

  10. Educational Codeforces Round 21 Problem A - C

    Problem A Lucky Year 题目传送门[here] 题目大意是说,只有一个数字非零的数是幸运的,给出一个数,求下一个幸运的数是多少. 这个幸运的数不是最高位的数字都是零,于是只跟最高位有 ...

随机推荐

  1. 使用 Laf 一周内上线美术狮 AI 绘画小程序

    "美术狮 AI 绘画"(以下简称"美术狮"),是我们小团队的一次尝试,定位是人人都可以上手的,充满创意的,理解中文和中国文化的图片生成工具. 在完善图像模型和论 ...

  2. 【译】.NET 8 拦截器(interceptor)

    通常情况下,出于多种原因,我不会说我喜欢写关于预览功能的文章.我的大多数帖子旨在帮助人们解决他们可能遇到的问题,而不是找个肥皂盒或打广告.但是我认为我应该介绍这个 .NET 预览特性,因为它是我在 . ...

  3. QA|新版Pycharm如何关闭和开启自动补全功能?|Pycharm|工具相关

    自动补全开启状态: 自动补全关闭状态: 建议:新学者建议开启自动补全,这样可以把各个函数方法记忆的更加深刻!

  4. 发现了一个可以免费下载jar包的网站,所有jar包都有

    苦苦找不到项目所需要的jar包?发现了一个可以免费下载jar包的网站: https://jar-download.com/ 非常好用. 每个JAR文件都将从官方Maven存储库下载.通过下载所有Mav ...

  5. 01.前后端分离中台框架后端 Admin.Core 学习-介绍与配置说明

    中台框架后端项目 Admin.Core 的介绍与配置说明 中台admin是前后端分离权限管理系统,Admin.Core为后端项目,基于.NET 7.0开发. 支持多租户.数据权限.动态 Api.任务调 ...

  6. 文心一言 VS 讯飞星火 VS chatgpt (111)-- 算法导论10.2 2题

    二.用go语言,用一个单链表 L实现一个栈.要求操作 PUSH和 POP 的运行时间仍为 O(1). 文心一言: 在 Go 语言中,我们可以用结构体来实现一个单链表,然后再用栈的相关操作. 以下是一个 ...

  7. 掌握 Kubernetes 故障排除:有效维护集群的最佳实践和工具

    Kubernetes 是一款管理容器化应用程序的强大工具.然而,与任何复杂的系统一样,使用它时也可能出错.当问题出现时, 掌握有效的故障排除技术和工具非常重要. 本文将介绍以下步骤,助您了解事件收集的 ...

  8. C++11 列表初始化都做了什么?

    类的成员变量的初始化细节 首先,来看两个问题: 类的构造函数中,成员变量的列表初始化是如何实现的? 为什么列表初始化效率上优于在构造函数中为成员变量赋值? (后文中,将 "在构造函数中为成员 ...

  9. 【Go 编程实践】从零到一:创建、测试并发布自己的 Go 库

    为什么需要开发自己的 Go 库 在编程语言中,包(Package)和库(Library)是代码组织和复用的重要工具.在 Go 中,包是代码的基本组织单位,每个 Go 程序都由包构成.包的作用是帮助组织 ...

  10. Python 机器学习入门:数据集、数据类型和统计学

    机器学习是通过研究数据和统计信息使计算机学习的过程.机器学习是迈向人工智能(AI)的一步.机器学习是一个分析数据并学会预测结果的程序. 数据集 在计算机的思维中,数据集是任何数据的集合.它可以是从数组 ...