codeforces-scrape

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

926G.md (1981B)


      1 Source: https://codeforces.com/problemset/problem/926/G
      2 
      3 G. Large Bouquets
      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 A flower shop has got *n* bouquets, and the *i*-th bouquet consists of *a**i* flowers. Vasya, the manager of the shop, decided to make large bouquets from these bouquets.
     22 
     23 Vasya thinks that a bouquet is large if it is made of two or more initial bouquets, and there is a constraint: the total number of flowers in a large bouquet should be odd. Each of the initial bouquets can be a part of at most one large bouquet. If an initial bouquet becomes a part of a large bouquet, all its flowers are included in the large bouquet.
     24 
     25 Determine the maximum possible number of large bouquets Vasya can make.
     26 
     27 Input
     28 
     29 The first line contains a single positive integer *n* (1 ≤ *n* ≤ 105) — the number of initial bouquets.
     30 
     31 The second line contains a sequence of integers *a*1, *a*2, ..., *a**n* (1 ≤ *a**i* ≤ 106) — the number of flowers in each of the initial bouquets.
     32 
     33 Output
     34 
     35 Print the maximum number of large bouquets Vasya can make.
     36 
     37 Examples
     38 
     39 Input
     40 
     41 ```
     42 5  
     43 2 3 4 2 7
     44 ```
     45 
     46 Output
     47 
     48 ```
     49 2
     50 ```
     51 
     52 Input
     53 
     54 ```
     55 6  
     56 2 2 6 8 6 12
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 0
     63 ```
     64 
     65 Input
     66 
     67 ```
     68 3  
     69 11 4 10
     70 ```
     71 
     72 Output
     73 
     74 ```
     75 1
     76 ```
     77 
     78 Note
     79 
     80 In the first example Vasya can make 2 large bouquets. For example, the first bouquet can contain the first and the fifth initial bouquets (the total number of flowers is then equal to 9), and the second bouquet can consist of the second and the third initial bouquets (the total number of flowers is then equal to 7). The fourth initial bouquet is unused in this scheme.
     81 
     82 In the second example it is not possible to form a single bouquet with odd number of flowers.
     83 
     84 In the third example Vasya can make one large bouquet. For example, he can make it using all three initial bouquets. The size of the large bouquet is then equal to 11 + 4 + 10 = 25.