codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

837C.md (1812B)


      1 Source: https://codeforces.com/problemset/problem/837/C
      2 
      3 C. Two Seals
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 One very important person has a piece of paper in the form of a rectangle *a* × *b*.
     22 
     23 Also, he has *n* seals. Each seal leaves an impression on the paper in the form of a rectangle of the size *x**i* × *y**i*. Each impression must be parallel to the sides of the piece of paper (but seal can be rotated by 90 degrees).
     24 
     25 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?
     26 
     27 Input
     28 
     29 The first line contains three integer numbers *n*, *a* and *b* (1 ≤ *n*, *a*, *b* ≤ 100).
     30 
     31 Each of the next *n* lines contain two numbers *x**i*, *y**i* (1 ≤ *x**i*, *y**i* ≤ 100).
     32 
     33 Output
     34 
     35 Print the largest total area that can be occupied by two seals. If you can not select two seals, print 0.
     36 
     37 Examples
     38 
     39 Input
     40 
     41 ```
     42 2 2 2  
     43 1 2  
     44 2 1
     45 ```
     46 
     47 Output
     48 
     49 ```
     50 4
     51 ```
     52 
     53 Input
     54 
     55 ```
     56 4 10 9  
     57 2 3  
     58 1 1  
     59 5 10  
     60 9 11
     61 ```
     62 
     63 Output
     64 
     65 ```
     66 56
     67 ```
     68 
     69 Input
     70 
     71 ```
     72 3 10 10  
     73 6 6  
     74 7 7  
     75 20 5
     76 ```
     77 
     78 Output
     79 
     80 ```
     81 0
     82 ```
     83 
     84 Note
     85 
     86 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.
     87 
     88 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.
     89 
     90 In the third example there is no such pair of seals that they both can fit on a piece of paper.