Skip to content

Commit

Permalink
[Add] 무지의 먹방 라이브 (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
heerucan committed Apr 10, 2022
1 parent 08d51e3 commit bbcf3e3
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
27 changes: 27 additions & 0 deletions CodingTest/CH3 그리디/무지의먹방라이브.py
Original file line number Diff line number Diff line change
@@ -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)
27 changes: 27 additions & 0 deletions CodingTest/CH4 구현/무지의먹방라이브.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit bbcf3e3

Please sign in to comment.