From bbcf3e329c9f5063e21cf76e35aa98526ea8f3ee Mon Sep 17 00:00:00 2001 From: heerucan Date: Sun, 10 Apr 2022 17:38:45 +0900 Subject: [PATCH] =?UTF-8?q?[Add]=20=EB=AC=B4=EC=A7=80=EC=9D=98=20=EB=A8=B9?= =?UTF-8?q?=EB=B0=A9=20=EB=9D=BC=EC=9D=B4=EB=B8=8C=20(#1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...51\353\235\274\354\235\264\353\270\214.py" | 27 +++++++++++++++++++ ...51\353\235\274\354\235\264\353\270\214.py" | 27 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 "CodingTest/CH3 \352\267\270\353\246\254\353\224\224/\353\254\264\354\247\200\354\235\230\353\250\271\353\260\251\353\235\274\354\235\264\353\270\214.py" create mode 100644 "CodingTest/CH4 \352\265\254\355\230\204/\353\254\264\354\247\200\354\235\230\353\250\271\353\260\251\353\235\274\354\235\264\353\270\214.py" diff --git "a/CodingTest/CH3 \352\267\270\353\246\254\353\224\224/\353\254\264\354\247\200\354\235\230\353\250\271\353\260\251\353\235\274\354\235\264\353\270\214.py" "b/CodingTest/CH3 \352\267\270\353\246\254\353\224\224/\353\254\264\354\247\200\354\235\230\353\250\271\353\260\251\353\235\274\354\235\264\353\270\214.py" new file mode 100644 index 0000000..4461a2e --- /dev/null +++ "b/CodingTest/CH3 \352\267\270\353\246\254\353\224\224/\353\254\264\354\247\200\354\235\230\353\250\271\353\260\251\353\235\274\354\235\264\353\270\214.py" @@ -0,0 +1,27 @@ +# food_times 배열 +# k초가 매개변수 +import heapq + +food_times1 = list(map(int, input().split())) +k1 = int(input()) + + +def solution(food_times, k): + answer = -1 + if sum(food_times) <= k: + return answer + while k >= 0: + for i in range(len(food_times)): + if food_times[i] == 0: + continue + else: + k -= 1 + heap = [] + food_times[i] -= 1 + heapq.heappush(heap, food_times[i]) + if k == -1: + answer = i + 1 + return answer + + +solution(food_times1, k1) \ No newline at end of file diff --git "a/CodingTest/CH4 \352\265\254\355\230\204/\353\254\264\354\247\200\354\235\230\353\250\271\353\260\251\353\235\274\354\235\264\353\270\214.py" "b/CodingTest/CH4 \352\265\254\355\230\204/\353\254\264\354\247\200\354\235\230\353\250\271\353\260\251\353\235\274\354\235\264\353\270\214.py" new file mode 100644 index 0000000..4461a2e --- /dev/null +++ "b/CodingTest/CH4 \352\265\254\355\230\204/\353\254\264\354\247\200\354\235\230\353\250\271\353\260\251\353\235\274\354\235\264\353\270\214.py" @@ -0,0 +1,27 @@ +# food_times 배열 +# k초가 매개변수 +import heapq + +food_times1 = list(map(int, input().split())) +k1 = int(input()) + + +def solution(food_times, k): + answer = -1 + if sum(food_times) <= k: + return answer + while k >= 0: + for i in range(len(food_times)): + if food_times[i] == 0: + continue + else: + k -= 1 + heap = [] + food_times[i] -= 1 + heapq.heappush(heap, food_times[i]) + if k == -1: + answer = i + 1 + return answer + + +solution(food_times1, k1) \ No newline at end of file