Another Contest 5 Problem 3 - Cutting Cheese Costs

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 1.0s
Memory limit: 256M

Problem type

Tudor is buying N blocks of cheese. Each block of cheese has a regular price and a discounted price.

Tudor has K coupons that allow him to buy a block of cheese for the discounted price instead of the regular price. Each coupon can be used for exactly one block of cheese.

Given that Tudor wants to buy all N blocks of cheese, compute the minimum amount of money he must spend.

Constraints

1 \le N \le 10^5

0 \le K \le N

1 \le d_i \le p_i \le 10^9

Input Specification

The first line contains two space separated integers, N and K.

The next N lines each contain two space separated integers, p_i and d_i representing the regular price and discounted price of block i, respectively.

Output Specification

Output the minimum amount of money Tudor must spend.

Sample Input

2 1
100 0
10 10

Sample Output

10

Comments


  • 2
    Pleedoh  commented on Oct. 20, 2019, 10:19 p.m. edited

    Can anyone help me with WA (Presentation Error, check your whitespace)?

    I literally just output the answer, there is no whitespace...


    • 3
      Tzak  commented on Oct. 21, 2019, 12:27 a.m.

      You should place a \n character at the end of your output.