codeforces-scrape

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

789A.md (2300B)


      1 Source: https://codeforces.com/problemset/problem/789/A
      2 
      3 A. Anastasia and pebbles
      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 Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she began to collect Uzhlyandian pebbles. At first, she decided to collect all the pebbles she could find in the park.
     22 
     23 She has only two pockets. She can put at most *k* pebbles in each pocket at the same time. There are *n* different pebble types in the park, and there are *w**i* pebbles of the *i*-th type. Anastasia is very responsible, so she never mixes pebbles of different types in same pocket. However, she can put different kinds of pebbles in different pockets at the same time. Unfortunately, she can't spend all her time collecting pebbles, so she can collect pebbles from the park only once a day.
     24 
     25 Help her to find the minimum number of days needed to collect all the pebbles of Uzhlyandian Central Park, taking into consideration that Anastasia can't place pebbles of different types in same pocket.
     26 
     27 Input
     28 
     29 The first line contains two integers *n* and *k* (1 ≤ *n* ≤ 105, 1 ≤ *k* ≤ 109) — the number of different pebble types and number of pebbles Anastasia can place in one pocket.
     30 
     31 The second line contains *n* integers *w*1, *w*2, ..., *w**n* (1 ≤ *w**i* ≤ 104) — number of pebbles of each type.
     32 
     33 Output
     34 
     35 The only line of output contains one integer — the minimum number of days Anastasia needs to collect all the pebbles.
     36 
     37 Examples
     38 
     39 Input
     40 
     41 ```
     42 3 2  
     43 2 3 4
     44 ```
     45 
     46 Output
     47 
     48 ```
     49 3
     50 ```
     51 
     52 Input
     53 
     54 ```
     55 5 4  
     56 3 1 8 9 7
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 5
     63 ```
     64 
     65 Note
     66 
     67 In the first sample case, Anastasia can collect all pebbles of the first type on the first day, of second type — on the second day, and of third type — on the third day.
     68 
     69 Optimal sequence of actions in the second sample case:
     70 
     71 * In the first day Anastasia collects 8 pebbles of the third type.
     72 * In the second day she collects 8 pebbles of the fourth type.
     73 * In the third day she collects 3 pebbles of the first type and 1 pebble of the fourth type.
     74 * In the fourth day she collects 7 pebbles of the fifth type.
     75 * In the fifth day she collects 1 pebble of the second type.