Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[forkyy] 230318 외벽점점 풀이 완료(해설 보고 풀이) #95

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions forkyy/python/mar/외벽점검.py
Original file line number Diff line number Diff line change
@@ -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명의 관리자만 사용하면 됨.