22 lines
312 B
Python
22 lines
312 B
Python
|
import io
|
||
|
import sys
|
||
|
|
||
|
sys.stdin = io.StringIO('''3 6
|
||
|
10 5
|
||
|
9 2
|
||
|
8 1
|
||
|
''') # 47
|
||
|
|
||
|
import math
|
||
|
|
||
|
n, m = map(int, input().split())
|
||
|
nums = []
|
||
|
for i in range(n):
|
||
|
a, b = map(int, input().split())
|
||
|
for j in range(math.ceil(a / b)):
|
||
|
nums.append(a)
|
||
|
a -= b
|
||
|
|
||
|
nums.sort(reverse=True)
|
||
|
print(sum(nums[:m]))
|