Algorithm/lanqiao/series13sheng/th_ac.py

22 lines
312 B
Python
Raw Normal View History

2022-04-09 12:19:47 +08:00
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]))