Agorithm/백준 알고리즘
백준 알고리즘 11256번 사탕(python)
kimjinho1
2021. 10. 26. 22:27
728x90
반응형
기본적인 그리디 알고리즘 문제이다.
for _ in range(int(input())):
j, N = map(int, input().split())
li = []
for i in range(N):
r, c = map(int, input().split())
li.append(r*c)
li.sort(reverse=True)
cnt = 0
while j > 0:
j -= li[cnt]
cnt += 1
print(cnt)
728x90
반응형