ylab 2022. 4. 24. 23:38

https://www.acmicpc.net/problem/18429

 

18429번: 근손실

웨이트 트레이닝을 좋아하는 어떤 대학원생은, 현재 3대 운동 중량 500의 괴력을 소유하고 있다. 다만, 하루가 지날 때마다 중량이 K만큼 감소한다. 예를 들어 K=4일 때, 3일이 지나면 중량이 488로

www.acmicpc.net

#모든 경우의수 해보고 아닌거 거르기
import itertools
N, K = map(int,input().split())
A = list(map(int,input().split()))
count=0
for weight in itertools.permutations(A,N):
    W = 500
    
    for w in weight:
        W+=w-K
        if W <500:
            break

    else:
        count+=1

print(count)


배운것

1. itertools permutations => 순열