codeforces-scrape

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

38C.md (2768B)


      1 Source: https://codeforces.com/problemset/problem/38/C
      2 
      3 C. Blinds
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 The blinds are known to consist of opaque horizontal stripes that can be rotated thus regulating the amount of light flowing in the room. There are *n* blind stripes with the width of 1 in the factory warehouse for blind production. The problem is that all of them are spare details from different orders, that is, they may not have the same length (it is even possible for them to have different lengths)
     22 
     23 Every stripe can be cut into two or more parts. The cuttings are made perpendicularly to the side along which the length is measured. Thus the cuttings do not change the width of a stripe but each of the resulting pieces has a lesser length (the sum of which is equal to the length of the initial stripe)
     24 
     25 After all the cuttings the blinds are constructed through consecutive joining of several parts, similar in length, along sides, along which length is measured. Also, apart from the resulting pieces an initial stripe can be used as a blind if it hasn't been cut. It is forbidden to construct blinds in any other way.
     26 
     27 Thus, if the blinds consist of *k* pieces each *d* in length, then they are of form of a rectangle of *k* × *d* bourlemeters.
     28 
     29 Your task is to find for what window possessing the largest possible area the blinds can be made from the given stripes if on technical grounds it is forbidden to use pieces shorter than *l* bourlemeter. The window is of form of a rectangle with side lengths as positive integers.
     30 
     31 Input
     32 
     33 The first output line contains two space-separated integers *n* and *l* (1 ≤ *n*, *l* ≤ 100). They are the number of stripes in the warehouse and the minimal acceptable length of a blind stripe in bourlemeters. The second line contains space-separated *n* integers *a**i*. They are the lengths of initial stripes in bourlemeters (1 ≤ *a**i* ≤ 100).
     34 
     35 Output
     36 
     37 Print the single number — the maximal area of the window in square bourlemeters that can be completely covered. If no window with a positive area that can be covered completely without breaking any of the given rules exist, then print the single number 0.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 4 2  
     45 1 2 3 4
     46 ```
     47 
     48 Output
     49 
     50 ```
     51 8
     52 ```
     53 
     54 Input
     55 
     56 ```
     57 5 3  
     58 5 5 7 3 1
     59 ```
     60 
     61 Output
     62 
     63 ```
     64 15
     65 ```
     66 
     67 Input
     68 
     69 ```
     70 2 3  
     71 1 2
     72 ```
     73 
     74 Output
     75 
     76 ```
     77 0
     78 ```
     79 
     80 Note
     81 
     82 In the first sample test the required window is 2 × 4 in size and the blinds for it consist of 4 parts, each 2 bourlemeters long. One of the parts is the initial stripe with the length of 2, the other one is a part of a cut stripe with the length of 3 and the two remaining stripes are parts of a stripe with the length of 4 cut in halves.