CF779C.Dishonest Sellers

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Igor found out discounts in a shop and decided to buy nn items. Discounts at the store will last for a week and Igor knows about each item that its price now is aia_{i} , and after a week of discounts its price will be bib_{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 kk 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 nn items.

输入格式

In the first line there are two positive integer numbers nn and kk ( 1<=n<=21051<=n<=2·10^{5} , 0<=k<=n0<=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 a1,a2,...,ana_{1},a_{2},...,a_{n} ( 1<=ai<=1041<=a_{i}<=10^{4} ) — prices of items during discounts (i.e. right now).

The third line contains sequence of integers b1,b2,...,bnb_{1},b_{2},...,b_{n} ( 1<=bi<=1041<=b_{i}<=10^{4} ) — prices of items after discounts (i.e. after a week).

输出格式

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

输入输出样例

  • 输入#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=106+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=253+4+10+3+5=25 .

首页