CF639D.Bear and Contribution
提高+/省选-
通过率:0%
时间限制:4.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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?
Codeforces 是一个优秀的平台,其特色功能之一是展示用户对社区的贡献程度。每位注册用户都有一个“贡献值”——一个整数(不一定是正数)。共有 $ n $ 位注册用户,其中第 $ i $ 位用户的贡献值为 $ t_i $。
Limak 是一只小北极熊,刚刚接触竞技编程。他甚至还没有 Codeforces 账号,但他可以给已有的博客和评论点赞。我们假设每位注册用户都拥有无限多的博客和评论。
- Limak 花费 $ b $ 分钟阅读并点赞一篇博客,该博客作者的贡献值将增加 $ 5 $;
- Limak 花费 $ c $ 分钟阅读并点赞一条评论,该评论作者的贡献值将增加 $ 1 $。
注意:Limak 阅读博客可能比阅读评论更快(即 $ b $ 可能小于 $ c $)。
Limak 喜欢平局(tie)。他认为,看到至少 $ k $ 位注册用户的贡献值完全相等,将会非常酷。为了实现这一目标,他将花费一定时间阅读并点赞。操作完成后,必须存在某个整数 $ x $,使得至少 $ k $ 位注册用户的贡献值恰好等于 $ x $。
Limak 至少需要花费多少时间才能达成目标?
输入格式
The first line contains four integers n, k, b and c (2 ≤ k ≤ n ≤ 200 000, 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| ≤ 109) where t__i denotes contribution of the i-th registered user.
第一行包含四个整数 n、k、b 和 c(2 ≤ k ≤ n ≤ 200000,1 ≤ b,c ≤ 1000)——分别表示注册用户的数量、要求具有相同贡献值的用户数的最小值、阅读并点赞一篇博客所需的时间、阅读并点赞一条评论所需的时间。
第二行包含 n 个整数 t1,t2,...,tn(∣ti∣ ≤ 109),其中 ti 表示第 i 个注册用户的贡献值。
输出格式
Print the minimum number of minutes Limak will spend to get a tie between at least k registered users.
输出Limak为使至少 k 名注册用户打成平局所需花费的最少分钟数。
输入输出样例
输入#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
说明/提示
In the first sample, there are 4 registered users and Limak wants a tie between at least 3 of them. Limak should behave as follows.
- He spends 100 minutes to read one blog of the 4-th user and increase his contribution from 1 to 6.
- Then he spends 4·30 = 120 minutes to read four comments of the 2-nd user and increase his contribution from 2 to 6 (four times it was increaded by 1).
In the given scenario, Limak spends 100 + 4·30 = 220 minutes and after that each of users 2, 3, 4 has contribution 6.
In the second sample, Limak needs 30 minutes to read a blog and 100 minutes to read a comment. This time he can get 3 users with contribution equal to 12 by spending 100 + 3·30 = 190 minutes:
- Spend 2·30 = 60 minutes to read two blogs of the 1-st user to increase his contribution from 2 to 12.
- Spend 30 + 100 minutes to read one blog and one comment of the 3-rd user. His contribution will change from 6 to 6 + 5 + 1 = 12.
在第一个样例中,共有 4 名注册用户,Limak 希望其中至少 3 人贡献值相同(即出现平局)。Limak 应按如下方式行动:
- 他花费 100 分钟阅读第 4 位用户的 1 篇博客,将其贡献值从 1 提升至 6;
- 接着,他花费 4⋅30=120 分钟阅读第 2 位用户的 4 条评论,将其贡献值从 2 提升至 6(每次提升 1,共提升 4 次)。
在此情形下,Limak 总共花费 100+4⋅30=220 分钟,之后用户 2、3、4 的贡献值均为 6。
在第二个样例中,Limak 阅读一篇博客需 30 分钟,阅读一条评论需 100 分钟。此时,他可通过花费 100+3⋅30=190 分钟,使 3 名用户的贡献值均达到 12:
- 花费 2⋅30=60 分钟阅读第 1 位用户的 2 篇博客,将其贡献值从 2 提升至 12;
- 花费 30+100 分钟阅读第 3 位用户的 1 篇博客和 1 条评论,其贡献值将从 6 变为 6+5+1=12。
输入解题思路,AI测评打分。不知道怎么写?