问题 G: Kill The Monsters

内存限制:256 MB 时间限制:1 S
题面:Markdown 评测方式:文本比较 上传者:
提交:7 通过:2

题目描述

There are $n$ monsters in the forest. The $i$\-th one has a defense value of $a_i$. You can perform the following attacks: 1\. Decrease all monsters' defense values by $1$. 2\. Choose a monster and let its defense value $a_i$ be $\lfloor\frac{a_i}{k}\rfloor$, where $k$ is given. Find the minimum number of operations required to make the defense value of each monster less than or eqaul to $0$.

输入格式

Line $1$: Two integers $n,k$. Line $2$: $n$ integers, indicating sequence $a$.

输出格式

Line $1$: An integer, the answer.

输入样例 复制

5 2
1 3 5 7 9

输出样例 复制

7

数据范围与提示

$1\leq n\leq 10^5$. $1\leq a_i,k\leq 10^9$.