Educational Codeforces Round 26 Problem C
C. Two Sealstime limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard 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?
InputThe 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).
OutputPrint the largest total area that can be occupied by two seals. If you can not select two seals, print 0.
Examplesinput2 2 2
1 2
2 1output4input4 10 9
2 3
1 1
5 10
9 11output56input3 10 10
6 6
7 7
20 5output0NoteIn 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的更多相关文章
- Educational Codeforces Round 26
Educational Codeforces Round 26 困到不行的场,等着中午显示器到了就可以美滋滋了 A. Text Volume time limit per test 1 second ...
- CodeForces 837F - Prefix Sums | Educational Codeforces Round 26
按tutorial打的我血崩,死活挂第四组- - 思路来自FXXL /* CodeForces 837F - Prefix Sums [ 二分,组合数 ] | Educational Codeforc ...
- CodeForces - 837E - Vasya's Function | Educational Codeforces Round 26
/* CodeForces - 837E - Vasya's Function [ 数论 ] | Educational Codeforces Round 26 题意: f(a, 0) = 0; f( ...
- CodeForces 837D - Round Subset | Educational Codeforces Round 26
/* CodeForces 837D - Round Subset [ DP ] | Educational Codeforces Round 26 题意: 选k个数相乘让末尾0最多 分析: 第i个数 ...
- 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 ...
- 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]代表已经选择 ...
- Educational Codeforces Round 26 B,C
B. Flag of Berland 链接:http://codeforces.com/contest/837/problem/B 思路:题目要求判断三个字母是否是条纹型的,而且宽和高相同,那么先求出 ...
- Educational Codeforces Round 21 Problem E(Codeforces 808E) - 动态规划 - 贪心
After several latest reforms many tourists are planning to visit Berland, and Berland people underst ...
- 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 ...
- Educational Codeforces Round 21 Problem A - C
Problem A Lucky Year 题目传送门[here] 题目大意是说,只有一个数字非零的数是幸运的,给出一个数,求下一个幸运的数是多少. 这个幸运的数不是最高位的数字都是零,于是只跟最高位有 ...
随机推荐
- 扩展ABP的Webhook功能,推送数据到第三方接口(企业微信群、钉钉群等)
前言 在上一篇文章[基于ASP.NET ZERO,开发SaaS版供应链管理系统]中有提到对Webhook功能的扩展改造,本文详细介绍一下具体过程. Webhook功能操作说明,请参见此文档链接:Web ...
- 【好玩】如何在github主页放一条贪吃蛇
前言 缘由 github放小蛇,就问你烧不烧 起因看到大佬github上有一条贪吃蛇扭来扭去,觉得好玩,遂给大家分享一下本狗的玩蛇历程 成果初展 贪吃蛇 访问地址 https://github.com ...
- Go语言常用标准库——context
文章目录 为什么需要Context 基本示例 全局变量方式 通道方式 官方版的方案 Context初识 Context接口 Background()和TODO() With系列函数 WithCance ...
- MySQL系列之MHA高可用——主从复制架构演变介绍、高可用MHA、管理员在高可用架构维护的职责
文章目录 1. 主从复制架构演变介绍 1.1 基本结构 1.2 高级应用架构演变 1.2.1 高性能架构 1.2.2 高可用架构 2. 高可用MHA ***** 2.1 架构工作原理 2.2 架构介绍 ...
- CUDA C编程权威指南:2.1-CUDA编程模型
本文主要通过例子介绍了CUDA异构编程模型,需要说明的是Grid.Block和Thread都是逻辑结构,不是物理结构.实现例子代码参考文献[2],只需要把相应章节对应的CMakeLists.txt ...
- 研发提速:nacos+openfeign环境下的本地链接服务
项目研发过程中,经常会遇到与测试人员工作重叠的情况,十分影响效率. 做了一个修改,可以在本地环境启动项目后和测试环境交互,并且不影响测试环境,理论上也可以用于线上环境的异常的快速处理. 准备事项如下: ...
- Python学习 —— 初步认知
写在前面 Python是一种流行的高级编程语言,具有简单易学.代码可读性高.应用广泛等优势.它是一种解释型语言,可以直接在终端或集成开发环境(IDE)中运行,而无需事先编译. Python的安装 Py ...
- jmeter生成HTML性能测试报告(非GUI的命令)
非GUI的命令(在cmd执行即可 不需要打开jmeter) 使用命令:jmeter -n -t [jmx file] -l [jtl file] -e -o [report path ...
- CF451B
题目简化和分析: 这题就是判断将一段翻转后是否能变为升序的数组. 我的方法是保存原数组每一个数出现的位置(相同任意一个),让后另外用一个数组存储排好序后的原数组,逐一进行比较. 若同,则跳到下一个元素 ...
- Epic资源转到unity的方法
众所周知,unity中的素材主要是通过unity资源商店获取的.但是unity资源商店的白嫖机会太少了,而隔壁UE的Epic资源商店就有每月免费的资源,不白嫖成何体统?但是UE咱也不会用啊,白嫖的资源 ...