상세 컨텐츠

본문 제목

[소프티어] 택배 마스터 광우

Algorithm

by 쑤야. 2024. 2. 1. 12:54

본문

 

https://softeer.ai/practice/6273

 

Softeer - 현대자동차그룹 SW인재확보플랫폼

 

softeer.ai

 

접근


  • 최소 무게를 들 수 있는 최적의 순서를 찾아야 한다
    순열 

 

코드


import sys
import itertools

n, m, k = list(map(int, sys.stdin.readline().split()))
w = list(map(int, sys.stdin.readline().split()))

answer = 2**128
for permutation in list(itertools.permutations(w, n)):
    p = 0
    temp = 0
    for i in range(k):
        tempW = 0
        while tempW + permutation[p] <= m:
            tempW += permutation[p]
            p = 0 if p == n-1 else p+1
        temp += tempW
    answer = min(answer, temp)
    
print(answer)

'Algorithm' 카테고리의 다른 글

관련글 더보기