Skip to content

Commit f5bde2c

Browse files
Merge pull request #631 from baekhangyeol/main
[백한결] 92차 라이브 코테 제출
2 parents 8d642eb + 4abd25e commit f5bde2c

3 files changed

Lines changed: 72 additions & 0 deletions

File tree

live9/test92/문제1/백한결.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import heapq
2+
3+
4+
def solution(scoville, K):
5+
count = 0
6+
7+
heapq.heapify(scoville)
8+
9+
while scoville[0] < K:
10+
if len(scoville) <= 1:
11+
count = -1
12+
break
13+
first_min_num = heapq.heappop(scoville)
14+
second_min_num = heapq.heappop(scoville)
15+
16+
mix_num = first_min_num + (second_min_num * 2)
17+
18+
heapq.heappush(scoville, mix_num)
19+
count += 1
20+
21+
return count

live9/test92/문제2/백한결.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
def solution(board, skill):
2+
count = 0
3+
4+
diff = [[0] * (len(board[0])+1) for _ in range(len(board) + 1)]
5+
6+
for type, r1, c1, r2, c2, degree in skill:
7+
if type == 1:
8+
degree = -degree
9+
10+
diff[r1][c1] += degree
11+
diff[r1][c2+1] -= degree
12+
diff[r2+1][c1] -= degree
13+
diff[r2+1][c2+1] += degree
14+
15+
for i in range(len(board)):
16+
for j in range(len(board[0])):
17+
diff[i][j+1] += diff[i][j]
18+
19+
for i in range(len(board)):
20+
for j in range(len(board[0])):
21+
diff[i+1][j] += diff[i][j]
22+
23+
for i in range(len(board)):
24+
for j in range(len(board[0])):
25+
board[i][j] += diff[i][j]
26+
if board[i][j] > 0:
27+
count +=1
28+
29+
return count

live9/test92/문제3/백한결.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
def solution(book_time):
2+
books = []
3+
4+
for start, end in book_time:
5+
books.append((hour_to_minutes(start), 1))
6+
books.append((hour_to_minutes(end) + 10, -1))
7+
8+
books.sort()
9+
10+
current_rooms = 0
11+
needed_rooms = 0
12+
13+
for time, type in books:
14+
current_rooms += type
15+
needed_rooms = max(needed_rooms, current_rooms)
16+
17+
return needed_rooms
18+
19+
20+
def hour_to_minutes(time):
21+
hour, minute = map(int, time.split(":"))
22+
return hour * 60 + minute

0 commit comments

Comments
 (0)