题库练习 Bear and Contribution
← 上一题 下一题 →

A10336 | Bear and Contribution

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Codeforces is a wonderful platform and one its feature shows how much someone contributes to the community. Every registered user has contribution — an integer number, not necessarily positive. There are $n$ registered users and the $i$ -th of them has contribution $t_{i}$ .

Limak is a little polar bear and he's new into competitive programming. He doesn't even have an account in Codeforces but he is able to upvote existing blogs and comments. We assume that every registered user has infinitely many blogs and comments.

- Limak can spend $b$ minutes to read one blog and upvote it. Author's contribution will be increased by $5$ .
- Limak can spend $c$ minutes to read one comment and upvote it. Author's contribution will be increased by $1$ .

Note that it's possible that Limak reads blogs faster than comments.

Limak likes ties. He thinks it would be awesome to see a tie between at least $k$ registered users. To make it happen he is going to spend some time on reading and upvoting. After that, there should exist an integer value $x$ that at least $k$ registered users have contribution exactly $x$ .

How much time does Limak need to achieve his goal?

输入格式

The first line contains four integers $n$ , $k$ , $b$ and $c$ ( $2<=k<=n<=200000,1<=b,c<=1000$ ) — the number of registered users, the required minimum number of users with the same contribution, time needed to read and upvote a blog, and time needed to read and upvote a comment, respectively.

The second line contains $n$ integers $t_{1},t_{2},...,t_{n}$ ( $|t_{i}|<=10^{9}$ ) where $t_{i}$ denotes contribution of the $i$ -th registered user.

输出格式

Print the minimum number of minutes Limak will spend to get a tie between at least $k$ registered users.

输入输出样例

输入 #1
4 3 100 30
12 2 6 1
输出 #1
220
输入 #2
4 3 30 100
12 2 6 1
输出 #2
190
输入 #3
6 2 987 789
-8 42 -4 -65 -8 -8
输出 #3
0
C++ 编辑器
输入
输出