zoukankan      html  css  js  c++  java
  • Educational Codeforces Round 26 Problem C

    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 }
  • 相关阅读:
    分区硬盘Lvm 折腾小记
    添加源ubuntu_x64 安装 Adobe Reader
    停止标记NYOJ 一个简单的数学题 南工330停止标记
    读控制台HDU 1788 Chinese remainder theorem again 数论读控制台
    对象方法PHP中魔术方法的用法对象方法
    指针修饰C语言const修饰符探秘指针修饰
    输入整数角谷步数 你听说过角谷猜想吗? 任意的正整数,比如 5, 我们从它开始,如下规则计算: 如果是偶数,则除以2,如果是奇数,则乘以3再加1. 如此循环,最终必会得到“1” !输入整数
    根节点左边POJ 1456 Supermarket根节点左边
    代码功能【OpenGL】初识OpenGL4.0代码功能
    终点节点NYOJ115 城市平乱终点节点
  • 原文地址:https://www.cnblogs.com/ISGuXing/p/7285084.html
Copyright © 2011-2022 走看看