효율적인 화폐구성1 [이취코] 효율적인 화폐 구성 (Python3) 처음에 짠 코드 n, m = map(int, input().split()) costs = [int(input()) for _ in range(n)] count = -1 d = [0] * 10000 for cost in costs: if m % cost == 0: count = m // cost else: count = -1 print(count) DP를 적용한 코드 n, m = map(int, input().split()) cost = [int(input()) for _ in range(n)] d = [10001] * (m+1) d[0] = 0 for i in range(n): # 3 for j in range(cost[i], m+1): # cost ~ 7 if d[j - cost[i]] != 10001.. 2024. 3. 6. 이전 1 다음