-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |