From 898c4a9c3ec22cc16a2dc523f6f74a3d56e9464b Mon Sep 17 00:00:00 2001 From: heeheejj Date: Fri, 20 Oct 2023 00:36:59 +0900 Subject: [PATCH] =?UTF-8?q?Week27=20PRG=2087946=20=ED=94=BC=EB=A1=9C?= =?UTF-8?q?=EB=8F=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...6_\355\224\274\353\241\234\353\217\204.py" | 24 +++++++++++++++++++ ...6_\355\224\274\353\241\234\353\217\204.py" | 24 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 "heeheej/programmers/PRG_87946_\355\224\274\353\241\234\353\217\204.py" create mode 100644 "heeheej/week27/PRG_87946_\355\224\274\353\241\234\353\217\204.py" diff --git "a/heeheej/programmers/PRG_87946_\355\224\274\353\241\234\353\217\204.py" "b/heeheej/programmers/PRG_87946_\355\224\274\353\241\234\353\217\204.py" new file mode 100644 index 0000000..b3d0f2e --- /dev/null +++ "b/heeheej/programmers/PRG_87946_\355\224\274\353\241\234\353\217\204.py" @@ -0,0 +1,24 @@ +# 피로도 +# 프로그래머스 코딩테스트 고득점 kit > 완전탐색 +# 1277 (+7) +# 순열 완전탐색 + +from itertools import permutations + +def solution(k, dungeons): + answer = -1 + N = len(dungeons) + arr = [i for i in range(N)] + perms = permutations(arr, N) + for perm in perms: + temp = k + cnt = 0 + for i in perm: + x, y = dungeons[i] + if x > temp: + break + else: + temp -= y + cnt += 1 + answer = max(answer, cnt) + return answer \ No newline at end of file diff --git "a/heeheej/week27/PRG_87946_\355\224\274\353\241\234\353\217\204.py" "b/heeheej/week27/PRG_87946_\355\224\274\353\241\234\353\217\204.py" new file mode 100644 index 0000000..b3d0f2e --- /dev/null +++ "b/heeheej/week27/PRG_87946_\355\224\274\353\241\234\353\217\204.py" @@ -0,0 +1,24 @@ +# 피로도 +# 프로그래머스 코딩테스트 고득점 kit > 완전탐색 +# 1277 (+7) +# 순열 완전탐색 + +from itertools import permutations + +def solution(k, dungeons): + answer = -1 + N = len(dungeons) + arr = [i for i in range(N)] + perms = permutations(arr, N) + for perm in perms: + temp = k + cnt = 0 + for i in perm: + x, y = dungeons[i] + if x > temp: + break + else: + temp -= y + cnt += 1 + answer = max(answer, cnt) + return answer \ No newline at end of file