CF120C.Winnie-the-Pooh and honey

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

As we all know, Winnie-the-Pooh just adores honey. Ones he and the Piglet found out that the Rabbit has recently gotten hold of an impressive amount of this sweet and healthy snack. As you may guess, Winnie and the Piglet asked to come at the Rabbit's place. Thus, there are nn jars of honey lined up in front of Winnie-the-Pooh, jar number ii contains aia_{i} kilos of honey. Winnie-the-Pooh eats the honey like that: each time he chooses a jar containing most honey. If the jar has less that kk kilos of honey or if Winnie-the-Pooh has already eaten from it three times, he gives the jar to Piglet. Otherwise he eats exactly kk kilos of honey from the jar and puts it back. Winnie does so until he gives all jars to the Piglet. Count how much honey Piglet will overall get after Winnie satisfies his hunger.

输入格式

The first line contains two integers nn and kk ( 1<=n<=100,1<=k<=1001<=n<=100,1<=k<=100 ). The second line contains nn integers a1a_{1} , a2a_{2} , ..., ana_{n} , separated by spaces ( 1<=ai<=1001<=a_{i}<=100 ).

输出格式

Print a single number — how many kilos of honey gets Piglet.

输入输出样例

  • 输入#1

    3 3
    15 8 10
    

    输出#1

    9
    
首页