CF779C.Dishonest Sellers

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Igor found out discounts in a shop and decided to buy n items. Discounts at the store will last for a week and Igor knows about each item that its price now is a__i, and after a week of discounts its price will be b__i.

Not all of sellers are honest, so now some products could be more expensive than after a week of discounts.

Igor decided that buy at least k of items now, but wait with the rest of the week in order to save money as much as possible. Your task is to determine the minimum money that Igor can spend to buy all n items.

伊戈尔发现了商店的折扣活动,决定购买 nn 件商品。该折扣活动将持续一周,伊戈尔知道每件商品当前的价格为 aia_i,而折扣结束后(即一周后)的价格为 bib_i。

并非所有商家都诚信经营,因此目前某些商品的价格可能反而高于折扣结束后的价格。

伊戈尔决定至少立即购买 kk 件商品,其余商品则等到一周后再购买,以尽可能节省开支。你的任务是计算伊戈尔购买全部 nn 件商品所需的最少花费。

输入格式

In the first line there are two positive integer numbers n and k (1 ≤ n ≤ 2·105, 0 ≤ k ≤ n) — total number of items to buy and minimal number of items Igor wants to by right now.

The second line contains sequence of integers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 104) — prices of items during discounts (i.e. right now).

The third line contains sequence of integers _b_1, _b_2, ..., b__n (1 ≤ b__i ≤ 104) — prices of items after discounts (i.e. after a week).

第一行包含两个正整数 nn 和 kk(1≤n≤2⋅1051 \leq n \leq 2 \cdot 10^5,0≤k≤n0 \leq k \leq n)—— 分别表示待购买的物品总数,以及 Igor 当前至少希望购买的物品数量。

第二行包含一个整数序列 a1,a2,…,ana_1, a_2, \dots, a_n(1≤ai≤1041 \leq a_i \leq 10^4)—— 表示各物品当前折扣期间的价格(即此刻的价格)。

第三行包含一个整数序列 b1,b2,…,bnb_1, b_2, \dots, b_n(1≤bi≤1041 \leq b_i \leq 10^4)—— 表示各物品折扣结束后的价格(即一周后的价格)。

输出格式

Print the minimal amount of money Igor will spend to buy all n items. Remember, he should buy at least k items right now.

输出伊戈尔购买全部 nn 件商品所需的最少花费。注意,他当前至少需要购买 kk 件商品。

输入输出样例

  • 输入#1

    3 1
    5 4 6
    3 1 5

    输出#1

    10
  • 输入#2

    5 3
    3 4 7 10 3
    4 5 5 12 5

    输出#2

    25

说明/提示

In the first example Igor should buy item 3 paying 6. But items 1 and 2 he should buy after a week. He will pay 3 and 1 for them. So in total he will pay 6 + 3 + 1 = 10.

In the second example Igor should buy right now items 1, 2, 4 and 5, paying for them 3, 4, 10 and 3, respectively. Item 3 he should buy after a week of discounts, he will pay 5 for it. In total he will spend 3 + 4 + 10 + 3 + 5 = 25.

在第一个例子中,伊戈尔应立即购买第 3 件商品,支付 6。而第 1 和第 2 件商品他应在一周后购买,分别支付 3 和 1。因此,他总共需支付 6+3+1=106 + 3 + 1 = 10。

在第二个例子中,伊戈尔应立即购买第 1、2、4 和 5 件商品,分别支付 3、4、10 和 3;第 3 件商品则应在折扣周之后购买,支付 5。因此,他总共需花费 3+4+10+3+5=253 + 4 + 10 + 3 + 5 = 25。

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

首页