From e112794a6f7eb846cca42a8553772086759ec682 Mon Sep 17 00:00:00 2001 From: SeokHo-Ham Date: Sat, 18 Mar 2023 16:24:33 +0900 Subject: [PATCH] =?UTF-8?q?230318=20=EC=99=B8=EB=B2=BD=EC=A0=90=EC=A0=90?= =?UTF-8?q?=20=ED=92=80=EC=9D=B4=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...70\353\262\275\354\240\220\352\262\200.py" | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 "forkyy/python/mar/\354\231\270\353\262\275\354\240\220\352\262\200.py" diff --git "a/forkyy/python/mar/\354\231\270\353\262\275\354\240\220\352\262\200.py" "b/forkyy/python/mar/\354\231\270\353\262\275\354\240\220\352\262\200.py" new file mode 100644 index 0000000..7ff3f34 --- /dev/null +++ "b/forkyy/python/mar/\354\231\270\353\262\275\354\240\220\352\262\200.py" @@ -0,0 +1,40 @@ +import math +from itertools import permutations + + +def solution(n, weak, dist): + answer = math.inf + weak_size = len(weak) + weak = weak + [w + n for w in weak] + cases = permutations(dist, len(dist)) + + for start_index in range(weak_size): + for workers in cases: + count = 1 + position = start_index + + for i in range(1, weak_size): + next_position = start_index + i + diff = weak[next_position] - weak[position] + + if diff > workers[count - 1]: + position = next_position + count += 1 + if count > len(dist): + break + + if count <= len(dist): + answer = min(answer, count) + + if answer == math.inf: + return -1 + + return answer + +# 1. 순열을 구해야함. + + +# 시작하는 취약지점을 돌아가며 +# dist의 순열을 전부 돌려본다. +# ex) 1 지점부터 시작 -> 1번, 2번, 3번 관리자를 사용함 +# ex) 5 지점부터 시작 -> 1번이 5번에서 시작 / 3번이 10번부터 시작. -> 2명의 관리자만 사용하면 됨.