← Back to List

11256번: 사탕 ↗

Solutions

Python 3
280 B | 280 chars
for _ in range(int(input())):
    J,N = map(int,input().split())
    L = []
    for i in range(N):
        a,b=map(int,input().split())
        L.append(a*b)
    L.sort(reverse=True)
    cnt = 0
    for i in L:
        if J > 0:
            J-= i
            cnt+=1
    print(cnt)