본문 바로가기
카테고리 없음

현대_Softeer_level3_택배 마스터 광우_파이썬

by WelcomeBro 2023. 8. 2.
반응형

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from itertools import permutations
 
line_num, max_basket, work_time = map(int,input().split())
weight_list = list(map(int,input().split()))
 
def count_total(weight_list):
    now_index = 0
    now_weight = 0
    total_weight = 0
    now_time = 0
    while work_time != now_time:
        if now_index == line_num:
            now_index -= line_num
        now_weight += weight_list[now_index]
        if now_weight>max_basket:
            now_time+=1
            total_weight += now_weight-weight_list[now_index]
            now_weight = 0
            continue
        else:
            now_index+=1
    return total_weight
 
rails_info = permutations(weight_list, line_num)
find_min = []
for now_rail in rails_info:
    a = count_total(list(now_rail))
    find_min.append(a)
print(min(find_min))
cs

 

Be positive!

Be rich!

Live your life!

반응형