Codeforces Round 407 (Div. 2)
A
Anastasia and pebbles
Codeforces
1100
原题
←B →
翻译中…

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.

翻译中…

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.

翻译中…

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.

翻译中…

Input

翻译中…

The first line contains two integers $*n*$ and $*k*$ ($1 ≤ *n* ≤ 10^{5}$, $1 ≤ *k* ≤ 10^{9}$) — the number of different pebble types and number of pebbles Anastasia can place in one pocket.

翻译中…

The second line contains $*n*$ integers $*w*_{1}, *w*_{2}, ..., *w*_{*n*}$ ($1 ≤ *w*_{*i*} ≤ 10^{4}$) — number of pebbles of each type.

翻译中…

Output

翻译中…

The only line of output contains one integer — the minimum number of days Anastasia needs to collect all the pebbles.

翻译中…

Note

翻译中…

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.

翻译中…

Optimal sequence of actions in the second sample case:

翻译中…
  • In the first day Anastasia collects $8$ pebbles of the third type.
  • In the second day she collects $8$ pebbles of the fourth type.
  • In the third day she collects $3$ pebbles of the first type and $1$ pebble of the fourth type.
  • In the fourth day she collects $7$ pebbles of the fifth type.
  • In the fifth day she collects $1$ pebble of the second type.
翻译中…

样例

Input #1
3 2
2 3 4
Output #1
3
InputCopy OutputCopy
Input #2
5 4
3 1 8 9 7
Output #2
5
InputCopy OutputCopy
题目信息
题号
789A
时间限制
1 s
内存限制
256 MB
标签
模拟
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。