Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions live9/test92/문제1/백한결.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import heapq


def solution(scoville, K):
count = 0

heapq.heapify(scoville)

while scoville[0] < K:
if len(scoville) <= 1:
count = -1
break
first_min_num = heapq.heappop(scoville)
second_min_num = heapq.heappop(scoville)

mix_num = first_min_num + (second_min_num * 2)

heapq.heappush(scoville, mix_num)
count += 1

return count
29 changes: 29 additions & 0 deletions live9/test92/문제2/백한결.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
def solution(board, skill):
count = 0

diff = [[0] * (len(board[0])+1) for _ in range(len(board) + 1)]

for type, r1, c1, r2, c2, degree in skill:
if type == 1:
degree = -degree

diff[r1][c1] += degree
diff[r1][c2+1] -= degree
diff[r2+1][c1] -= degree
diff[r2+1][c2+1] += degree

for i in range(len(board)):
for j in range(len(board[0])):
diff[i][j+1] += diff[i][j]

for i in range(len(board)):
for j in range(len(board[0])):
diff[i+1][j] += diff[i][j]

for i in range(len(board)):
for j in range(len(board[0])):
board[i][j] += diff[i][j]
if board[i][j] > 0:
count +=1

return count
22 changes: 22 additions & 0 deletions live9/test92/문제3/백한결.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
def solution(book_time):
books = []

for start, end in book_time:
books.append((hour_to_minutes(start), 1))
books.append((hour_to_minutes(end) + 10, -1))

books.sort()

current_rooms = 0
needed_rooms = 0

for time, type in books:
current_rooms += type
needed_rooms = max(needed_rooms, current_rooms)

return needed_rooms


def hour_to_minutes(time):
hour, minute = map(int, time.split(":"))
return hour * 60 + minute