programmers - 더맵게[level2] - python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import heapq
def solution(scoville, K):
    answer = 0
    scoville.sort()
    scoville = [scoville[i] for i in range(0len(scoville)) if scoville[i] <= K]
 
    try:
        while 1:
            if scoville[0<= K:
                heapq.heappush(scoville, heapq.heappop(scoville) + (heapq.heappop(scoville) * 2))
                answer += 1
            else:
                break
    except:
        return -1
    return answer
cs



요약: python빨 오지네

  • 네이버 블로그 공유
  • 네이버 밴드 공유
  • 페이스북 공유
  • 카카오스토리 공유