zoukankan      html  css  js  c++  java
  • C. Two Seals

    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.

    这题一开始想简单了,结果哇了好几次。其实就是很简单。

    由于数据量太小,就直接暴力枚举就成了。

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstring>
     4 #include <set>
     5 #include <algorithm>
     6 using namespace std;
     7 struct Node{
     8     int x,y,z;
     9 }node[105];
    10 int main(){
    11     int k,n,m,a,b,xn,xm,Max=0;
    12     cin>>k>>n>>m;
    13     a=max(n,m);
    14     b=min(n,m);
    15     for(int i=1;i<=k;i++){
    16         cin>>xn>>xm;
    17         node[i].x=max(xn,xm);
    18         node[i].y=min(xn,xm);
    19         node[i].z=xn*xm;
    20     }
    21 
    22     for(int i=1;i<=k-1;i++){
    23         for(int j=i+1;j<=k;j++){
    24             if(node[i].x<=b&&node[j].x<=b&&(node[i].y+node[j].y)<=a)
    25                 Max=max(Max,(node[i].z+node[j].z));
    26             if(node[i].y<=b&&node[j].y<=b&&(node[j].x+node[i].x)<=a)
    27                 Max=max(Max,(node[i].z+node[j].z));
    28             if(node[i].x<=a&&node[j].x<=a&&(node[i].y+node[j].y)<=b)
    29                 Max=max(Max,(node[i].z+node[j].z));
    30             if(node[i].y<=a&&node[j].y<=a&&(node[i].x+node[j].x)<=b)
    31                 Max=max(Max,(node[i].z+node[j].z));
    32             if(node[i].x<=b&&node[j].y<=b&&(node[i].y+node[j].x)<=a)
    33                 Max=max(Max,(node[i].z+node[j].z));
    34             if(node[i].x<=a&&node[j].y<=a&&(node[i].y+node[j].x)<=b)
    35                 Max=max(Max,(node[i].z+node[j].z));
    36             if(node[i].y<=a&&node[j].x<=a&&(node[i].x+node[j].y)<=b)
    37                 Max=max(Max,(node[i].z+node[j].z));
    38             if(node[i].y<=b&&node[j].x<=b&&(node[i].x+node[j].y)<=a)
    39                 Max=max(Max,(node[i].z+node[j].z));
    40         }
    41     }
    42     cout<<Max<<endl;
    43     return 0;
    44 }
  • 相关阅读:
    Useful NumPy functions: Reshape, Argpartition, Clip, Extract, Setdiff1d
    Review of Semantic Segmentation with Deep Learning
    Dice Similarity Coefficent vs. IoU Dice系数和IoU
    Fix multiple GPUs fails in training Mask_RCNN
    Instance Segmentation with Mask R-CNN and TensorFlow
    条件随机场CRF原理介绍 以及Keras实现
    5个数组Array方法: indexOf、filter、forEach、map、reduce使用实例
    Map 数据结构
    Symbol
    箭头函数
  • 原文地址:https://www.cnblogs.com/zllwxm123/p/7283615.html
Copyright © 2011-2022 走看看