개발자 톡

연습문제 톡 금고털이

파이썬인데 TC 5만 계속 오류가 나네요 ㅠㅠ

등록일
2024-01-11 16:34:04
조회수
420
작성자
jeje5208
w, n = map(int, input().split())

lst_m = []
lst_p = []
price = []

for i in range(n):
    m, p = map(int, input().split())
    lst_m.append(m)
    lst_p.append(p)
    
max_m = lst_m[lst_p.index(max(lst_p))]

while w > 0:
    if w > max_m:
        price.append(max_m * max(lst_p))
        w = w - max_m
        lst_m.pop(lst_p.index(max(lst_p)))
        lst_p.remove(max(lst_p))
    else:
        price.append(w * max(lst_p))
        break


print(sum(price))
#금고털이

이 카테고리의 톡 더보기