文章
5
粉丝
211
获赞
1
访问
8.9k
while True: try: x, n = map(int, (input().split())) if x == n == -1: break drink = [0 for i in range(n)] for i in range(n): drink[i] = list(map(int, input().split())) drink.sort(key=lambda x: x[1] / x[0]) ans = 0 for i in range(n): if x >= drink[i][1]: x -= drink[i][1] ans += drink[i][0] # print(drink[i][0]) else: t = x * drink[i][0] / drink[i][1] ans += t # print(t) break print("%.3f" % ans) except: break
登录后发布评论
暂无评论,来抢沙发