CF873A.Chores

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Luba has to do n chores today. i-th chore takes a__i units of time to complete. It is guaranteed that for every the condition a__i ≥ a__i - 1 is met, so the sequence is sorted.

Also Luba can work really hard on some chores. She can choose not more than k any chores and do each of them in x units of time instead of a__i ().

Luba is very responsible, so she has to do all n chores, and now she wants to know the minimum time she needs to do everything. Luba cannot do two chores simultaneously.

露芭今天需要完成 nn 项家务。第 ii 项家务需要 aia_i 单位时间才能完成。已知对每个 i∈[2,n]i \in [2, n],均满足条件 ai≥ai−1a_i \ge a_{i-1},因此该序列是非递减的。

此外,露芭可以在某些家务上格外努力。她最多可以选择 kk 项任意家务,将每项所用时间由 aia_i 减少为 xx(其中 x<aix < a_i)。

露芭非常有责任心,因此她必须完成全部 nn 项家务;现在她想知道完成所有家务所需的最少时间。露芭不能同时进行两项家务。

输入格式

The first line contains three integers n, k, x (1 ≤ k ≤ n ≤ 100, 1 ≤ x ≤ 99) — the number of chores Luba has to do, the number of chores she can do in x units of time, and the number x itself.

The second line contains n integer numbers a__i (2 ≤ a__i ≤ 100) — the time Luba has to spend to do i-th chore.

It is guaranteed that , and for each a__i ≥ a__i - 1.

第一行包含三个整数 nn、kk、xx(1 ≤ k ≤ n ≤ 1001 ≤ k ≤ n ≤ 100,1 ≤ x ≤ 991 ≤ x ≤ 99)——分别表示鲁芭需要完成的家务总数、她能在 xx 个单位时间内完成的家务数量,以及数值 xx 本身。

第二行包含 nn 个整数 aia_i(2 ≤ ai ≤ 1002 ≤ a_i ≤ 100)——表示鲁芭完成第 ii 项家务所需的时间。

题目保证 ,且对每个 均有 ai ≥ ai−1a_i ≥ a_{i-1}。

输出格式

Print one number — minimum time Luba needs to do all n chores.

输出一个数字——Luba 完成所有 nn 项家务所需的最少时间。

输入输出样例

  • 输入#1

    4 2 2
    3 6 7 10

    输出#1

    13
  • 输入#2

    5 2 1
    100 100 100 100 100

    输出#2

    302

说明/提示

In the first example the best option would be to do the third and the fourth chore, spending x = 2 time on each instead of _a_3 and _a_4, respectively. Then the answer is 3 + 6 + 2 + 2 = 13.

In the second example Luba can choose any two chores to spend x time on them instead of a__i. So the answer is 100·3 + 2·1 = 302.

在第一个例子中,最优方案是选择第三项和第四项家务,每项花费 x=2x = 2 的时间,而非原本的 a3a_3 和 a4a_4。因此答案为 3+6+2+2=133 + 6 + 2 + 2 = 13。

在第二个例子中,Luba 可任选两项家务,对它们各花费 xx 时间,而非原本的 aia_i。因此答案为 100⋅3+2⋅1=302100 \cdot 3 + 2 \cdot 1 = 302。

输入解题思路,AI测评打分。不知道怎么写?

首页