Written by
최태열
on
on
[Python][프로그래머스][Level4] 무지의 먹방라이브
[Python][프로그래머스][Level4] 무지의 먹방라이브
코드
def solution(food_times, k):
food_times=[[num,idx+1] for idx,num in enumerate(food_times)]
food_times.sort(reverse=True)
eaten=0
min_food=food_times[-1][0]
while k-((min_food-eaten)*len(food_times))>=0:
k-=(min_food-eaten)*len(food_times)
eaten,idx=food_times.pop()
if not food_times:
return -1
min_food=food_times[-1][0]
food_times.sort(key= lambda x: (x[1]))
return food_times[k%len(food_times)][1]
Discussion and feedback